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