Norbert Koch <nk(a)LF.net> writes:
Index: udp2tcp.cc
===================================================================
RCS file: /usr/CVSroot/XEmacs/xemacs-packages/comm/eicq/udp2tcp.cc,v
retrieving revision 1.2
diff -u -r1.2 udp2tcp.cc
--- udp2tcp.cc 2000/10/23 15:48:59 1.2
+++ udp2tcp.cc 2001/01/21 13:45:19
@@ -334,7 +334,7 @@
printf("accepting....\n");
size_t sin_size = sizeof(struct sockaddr_in);
tcp_new_sock = accept(tcp_sock, (struct sockaddr *)&tcp_remote_addr,
- &sin_size);
+ (int *)&sin_size);
Actually, I believe this patch is bad juju on big endian 64-bit
systems like LP64 Solaris (and so is the original code). Recently I
spent two hours fixing a bug in Wget introduced by such a cast.
In short: sin_size is declared as size_t, which is a 64-bit quantity
on 64-bit machines. Casting its pointer to int * silences the
compiler, but introduces a problem, because the callee will believe it
got a pointer to a 32-bit quantity and simply read the first four
bytes of (int *)&sin_size, therefore getting the high 32 bits, all
zeroes.
The correct fix is to correctly declare sin_size in the first place.
It should be declared as a 32-bit quantity, such as socklen_t. (For
XEmacs, a mere `int' will also do.) After that, no cast should be
necessary.