1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177
|
Description: fix inconsistent types
C-Kermit 9 on OpenBSD on sparc64 gets a "Bus error" and dumps core when
receiving a file.
.
I compiled with "-g" and determined the location of the error:
.
[37] erb@netra:~/tmp/kermit$ gdb wermit wermit.core
GNU gdb 6.3
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain
conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "sparc64-unknown-openbsd4.8"...
Core was generated by `wermit'.
Program terminated with signal 10, Bus error.
Reading symbols from /usr/lib/libcurses.so.11.0...done.
Loaded symbols for /usr/lib/libcurses.so.11.0
Reading symbols from /usr/lib/libutil.so.11.1...done.
Loaded symbols for /usr/lib/libutil.so.11.1
Reading symbols from /usr/lib/libm.so.5.2...done.
Loaded symbols for /usr/lib/libm.so.5.2
Reading symbols from /usr/lib/libc.so.56.0...done.
Loaded symbols for /usr/lib/libc.so.56.0
Reading symbols from /usr/libexec/ld.so...done.
Loaded symbols for /usr/libexec/ld.so
#0 0x00000000001b15e8 in wart () at ckcpro.c:1510
1510 if (dest == DEST_N)
(gdb) bt
#0 0x00000000001b15e8 in wart () at ckcpro.c:1510
#1 0x00000000001c0f34 in xxproto () at ckcpro.c:3579
#2 0x00000000001beaac in proto () at ckcpro.c:3141
#3 0x0000000000105974 in doicp (threadinfo=0x0) at ckcmai.c:2420
#4 0x000000000038840c in cc_execute (sj_buf=0xb59120, dofunc=0x1057c4
<doicp>, failfunc=0x10597c <failicp>) at ckusig.c:171
#5 0x000000000010961c in main (argc=1, argv=0xfffffffffffc7ff8) at
ckcmai.c:3551
(gdb) quit
[38] erb@netra:~/tmp/kermit$
.
That line number 1510 in ckcpro.c corresponds to line 1434 of ckcpro.w:
.
1429 debug(F101,"<rfile>F winlo 1","",winlo);
1430 xflg = 0; /* Not screen data */
1431 if (!czseen)
1432 cancel = 0; /* Reset cancellation counter */
1433 #ifdef CALIBRATE
1434 if (dest == DEST_N)
1435 calibrate = 1;
1436 #endif /* CALIBRATE */
1437 if (!rcvfil(filnam)) { /* Figure out local filename */
1438 errpkt((CHAR *)rf_err); /* Trouble */
1439 RESUME;
.
And that leads us to the source of the problem. On line 155 of ckcpro.w,
dest is declared as a long:
.
155 extern long speed, ffc, crc16, calibrate, dest;
.
but on line 1313 of ckcmai.c dest is declared as an int:
.
1296 int deblog = 0, /* Debug log is open */
[snip]
1313 dest = DEST_D, /* Destination for packet
data */
.
In the process of checking some of the other extern declarations for
consistency, I discovered that lint will report these errors. The lint
output
is below. (I suppose there could also be some inconsistencies hiding behind
#ifdef's -- I didn't investigate things that deeply.)
.
[60] erb@netra:~/tmp/kermit$ lint *.c | grep "declared inconsistently" |
grep -v llib-lc
ckcmai.c:1277: filcnt declared inconsistently (ckcpro.c:85)
ckcmai.c:1017: calibrate declared inconsistently (ckcpro.c:177)
ckucmd.c:309: prevcmd declared inconsistently (ckuus5.c:3103)
ckcmai.c:636: cmdfil declared inconsistently (ckuusy.c:109)
ckcmai.c:1313: dest declared inconsistently (ckcpro.c:177)
ckcmai.c:1015: fsize declared inconsistently (ckcpro.c:1588)
ckcmai.c:1274: ffc declared inconsistently (ckcpro.c:177)
ckudia.c:293: dialcapas declared inconsistently (ckuusx.c:2364)
ckcmai.c:1278: filrej declared inconsistently (ckcpro.c:233)
[61] erb@netra:~/tmp/kermit$
.
The prevcmd and cmdfil inconsistencies are character array versus character
pointer issues and I don't know whether they're real problems or not. The
rest of the inconsistencies are addressed in the attached patch.
.
The patched kermit no longer crashes when receiving files on
openbsd/sparc64.
I tested that the patched kermit can build and send and receive files on
both openbsd/sparc64 and linux/x86_64 (CentOS 5).
From: Edward Berner <erb@bernerfam.com>
Origin: upstream, via private mail
Last-Update: 2012-05-09
Index: ckermit/ckcpro.w
===================================================================
--- ckermit.orig/ckcpro.w 2012-05-09 05:25:12.000000000 +0100
+++ ckermit/ckcpro.w 2012-05-09 05:26:59.000000000 +0100
@@ -60,7 +60,8 @@
extern int timint, rtimo, nfils, hcflg, xflg, flow, mdmtyp, network;
extern int oopts, omode, oname, opath, nopush, isguest, xcmdsrc, rcdactive;
extern int rejection, moving, fncact, bye_active, urserver, fatalio;
- extern int protocol, prefixing, filcnt, carrier, fnspath, interrupted;
+ extern int protocol, prefixing, carrier, fnspath, interrupted;
+ extern long filcnt;
extern int recursive, inserver, nzxopts, idletmo, srvidl, xfrint;
extern struct ck_p ptab[];
extern int remfile, rempipe, xferstat, filestatus, wearealike, fackpath;
@@ -151,8 +152,9 @@
extern int quiet, tsecs, parity, backgrd, nakstate, atcapu, wslotn, winlo;
extern int wslots, success, xitsta, rprintf, discard, cdtimo, keep, fdispla;
extern int timef, stdinf, rscapu, sendmode, epktflg, epktrcvd, epktsent;
- extern int binary, fncnv;
- extern long speed, ffc, crc16, calibrate, dest;
+ extern int binary, fncnv, dest;
+ extern long speed, crc16;
+ CK_OFF_T calibrate, ffc;
#ifdef COMMENT
extern char *TYPCMD, *DIRCMD, *DIRCM2;
#endif /* COMMENT */
@@ -208,8 +210,9 @@
static VOID
wheremsg() {
- extern int quiet, filrej;
- int n;
+ extern int quiet;
+ extern long filrej;
+ long n;
n = filcnt - filrej;
debug(F101,"wheremsg n","",n);
@@ -247,7 +250,7 @@
switch (myjob) {
case 's':
if (sfspec) {
- printf(" SENT: (%d files)",n);
+ printf(" SENT: (%ld files)",n);
if (srfspec)
printf(" Last: [%s]",srfspec);
printf(" (%s)\r\n", success ? "OK" : "FAILED");
@@ -256,7 +259,7 @@
case 'r':
case 'v':
if (rrfspec) {
- printf(" RCVD: (%d files)",n);
+ printf(" RCVD: (%ld files)",n);
if (rfspec)
printf(" Last: [%s]",rfspec);
printf(" (%s)\r\n", success ? "OK" : "FAILED");
@@ -1507,7 +1510,7 @@
ack(); /* If OK, acknowledge */
#endif /* CK_RESEND */
} else { /* Otherwise */
- extern long fsize;
+ extern CK_OFF_T fsize;
char *r;
r = getreason(iattr.reply.val);
ack1((CHAR *)iattr.reply.val); /* refuse to accept the file */
Index: ckermit/ckuusx.c
===================================================================
--- ckermit.orig/ckuusx.c 2012-05-09 05:25:12.000000000 +0100
+++ ckermit/ckuusx.c 2012-05-09 05:26:59.000000000 +0100
@@ -2361,7 +2361,8 @@
setflow() {
extern int flow, autoflow, mdmtyp, cxtype, cxflow[];
#ifndef NODIAL
- extern int dialcapas, dialfc;
+ extern int dialfc;
+ extern long dialcapas;
extern MDMINF * modemp[];
MDMINF * p = NULL;
long bits = 0;
|