I'm trying to get tightvncserver working on amd64. Changing the localtime() call in rfbLog to a localtime_r(), and moving it outside the strftime() invocation does indeed fix the reported problem. (See first patch attached). However, there are still some problems which remain:
gcc-3.3 seems to miscompile the package, throwing a SIGILL when run. Compiling with gcc-3.4 deals with that problem. At this point, the server apparently runs successfully. An attempted connection to the server causes a segfault again, this time in a call to inet_ntoa() in sockets.c. Replacing this with a call to inet_ntop() (see second patch attached) still segfaults in inet_ntop, and I can't see why: -------------- Program received signal SIGSEGV, Segmentation fault. 0x00002aaaab15eae1 in inet_ntop () from /lib/libc.so.6 (gdb) bt #0 0x00002aaaab15eae1 in inet_ntop () from /lib/libc.so.6 #1 0x00000000004bcd18 in rfbCheckFds () at sockets.c:207 #2 0x00000000004bc140 in ProcessInputEvents () at init.c:724 #3 0x0000000000437bc4 in Dispatch () at dispatch.c:244 #4 0x000000000041d91d in main (argc=3, argv=0x7fffffb4c748) at main.c:400 (gdb) up #1 0x00000000004bcd18 in rfbCheckFds () at sockets.c:207 207 if(inet_ntop(AF_INET, addr.sin_addr, namebuf, 1024) == NULL) { (gdb) print namebuf $1 = 0x76adb0 "[EMAIL PROTECTED]" (gdb) print addr $2 = {sin_family = 2, sin_port = 21153, sin_addr = {s_addr = 117440522}, sin_zero = "\000\000\000\000\000\000\000"} -------------- I hope this is vaguely useful. Let me know if there's anything more I can do to help get Xtightvnc working on amd64. Hugo. -- === Hugo Mills: [EMAIL PROTECTED] carfax.org.uk | darksatanic.net | lug.org.uk === PGP key: 1C335860 from wwwkeys.eu.pgp.net or http://www.carfax.org.uk --- Jenkins! Chap with the wings there! Five rounds rapid! ---
diff -urpN tightvnc-1.2.9-orig/Xvnc/programs/Xserver/hw/vnc/init.c tightvnc-1.2.9/Xvnc/programs/Xserver/hw/vnc/init.c --- tightvnc-1.2.9-orig/Xvnc/programs/Xserver/hw/vnc/init.c 2002-10-27 12:36:02.000000000 +0000 +++ tightvnc-1.2.9/Xvnc/programs/Xserver/hw/vnc/init.c 2006-05-20 19:46:41.000000000 +0100 @@ -59,6 +59,7 @@ from the X Consortium. #include <sys/socket.h> #include <netinet/in.h> #include <netdb.h> +#include <time.h> #include "X11/X.h" #define NEED_EVENTS #include "X11/Xproto.h" @@ -940,13 +941,22 @@ void rfbLog(char *format, ...) va_list args; char buf[256]; time_t clock; + struct tm loc; va_start(args, format); time(&clock); - strftime(buf, 255, "%d/%m/%y %T ", localtime(&clock)); + localtime_r(&clock, &loc); + strftime(buf, 255, "%d/%m/%y %T ", &loc); fprintf(stderr, buf); + if(format == NULL) + { + fprintf(stderr, "format was null\n"); + va_end(args); + return; + } + vfprintf(stderr, format, args); fflush(stderr);
diff -urpN tightvnc-1.2.9-orig/Xvnc/programs/Xserver/hw/vnc/sockets.c tightvnc-1.2.9/Xvnc/programs/Xserver/hw/vnc/sockets.c --- tightvnc-1.2.9-orig/Xvnc/programs/Xserver/hw/vnc/sockets.c 2002-10-27 12:36:02.000000000 +0000 +++ tightvnc-1.2.9/Xvnc/programs/Xserver/hw/vnc/sockets.c 2006-05-20 19:48:25.000000000 +0100 @@ -161,6 +161,7 @@ rfbCheckFds() const int one = 1; int sock; static Bool inetdInitDone = FALSE; + char *namebuf; if (!inetdInitDone && inetdSock != -1) { rfbNewClientConnection(inetdSock); @@ -201,18 +202,30 @@ rfbCheckFds() } fprintf(stderr,"\n"); + + namebuf = (char*)malloc(INET_ADDRSTRLEN+1); + if(inet_ntop(AF_INET, addr.sin_addr, namebuf, INET_ADDRSTRLEN) == NULL) { + int errsv = errno; + if(errsv == EAFNOSUPPORT) { + rfbLog("No IPv4 support"); + } else if(errsv == ENOSPC) { + rfbLog("Not enough space to write name"); + strncpy(namebuf, "xxx", INET_ADDRSTRLEN); + namebuf[INET_ADDRSTRLEN] = 0; + } + } #if USE_LIBWRAP - if (!hosts_ctl("Xvnc", STRING_UNKNOWN, inet_ntoa(addr.sin_addr), + if (!hosts_ctl("Xvnc", STRING_UNKNOWN, namebuf, STRING_UNKNOWN)) { - rfbLog("Rejected connection from client %s\n", - inet_ntoa(addr.sin_addr)); + rfbLog("Rejected connection from client %s\n", namebuf); close(sock); return; } #endif - rfbLog("Got connection from client %s\n", inet_ntoa(addr.sin_addr)); + rfbLog("Got connection from client %s\n", namebuf); + free(namebuf); AddEnabledDevice(sock); FD_SET(sock, &allFds);
signature.asc
Description: Digital signature