
The files tzcode95b.tar.gz and tzdata95b.tar.gz are now available by anonymous ftp from elsie.nci.nih.gov. Minor changes in both: the "code" file contains a workaround for the lack of "unistd.h" in Microsoft C++ version 7; the "data" file contains a fixed "Link" for America/Shiprock. --ado

: The files tzcode95b.tar.gz and tzdata95b.tar.gz are now available by anonymous : ftp from elsie.nci.nih.gov. Minor changes in both: the "code" file contains : a workaround for the lack of "unistd.h" in Microsoft C++ version 7; the "data" : file contains a fixed "Link" for America/Shiprock. I've picked up the new code and see that the tzload() code is still using FILENAME_MAX. There is a practical problem here. On many systems, the maximum pathname is something like 256 or 1024 (as defined by PATHMAX in limits.h (assuming something like a Posix system). This makes the intent of the code unrealisable (ie that TZDIR can be used to specify which zone file to read). One could argue that these systems are broken :-( Why not avoid the problem altogether and simply allocate sufficient memory for the constructed filename? I enclose a patch below. Earl -- +-------------------------------------------------------------------------+ | Earl Chew Email: earl@hpato.aus.hp.com | | Australian Telecom Operation Voice: +61 3 272 8380 | | Hewlett-Packard Australia Ltd Fax: +61 3 898 9257 | | 31 Joseph St, Blackburn 3130, Australia GPS: 37 48'44"S 145 8'51"E | +-------------------------------------------------------------------------+ *** localtime.c.orig Sat Mar 11 15:13:34 1995 --- localtime.c Sat Mar 11 15:33:00 1995 *************** *** 259,280 **** return -1; { register int doaccess; ! /* ! ** Section 4.9.1 of the C standard says that ! ** "FILENAME_MAX expands to an integral constant expression ! ** that is the sie needed for an array of char large enough ! ** to hold the longest file name string that the implementation ! ** guarantees can be opened." ! */ ! char fullname[FILENAME_MAX + 1]; if (name[0] == ':') ++name; doaccess = name[0] == '/'; if (!doaccess) { if ((p = TZDIR) == NULL) return -1; ! if ((strlen(p) + strlen(name) + 1) >= sizeof fullname) return -1; (void) strcpy(fullname, p); (void) strcat(fullname, "/"); --- 259,275 ---- return -1; { register int doaccess; ! char *fullname; + fullname = NULL; if (name[0] == ':') ++name; doaccess = name[0] == '/'; if (!doaccess) { if ((p = TZDIR) == NULL) return -1; ! fullname = malloc(strlen(p) + 1 + strlen(name) + 1); ! if (fullname == NULL) return -1; (void) strcpy(fullname, p); (void) strcat(fullname, "/"); *************** *** 286,295 **** doaccess = TRUE; name = fullname; } ! if (doaccess && access(name, R_OK) != 0) ! return -1; ! if ((fid = open(name, OPEN_MODE)) == -1) return -1; } { struct tzhead * tzhp; --- 281,296 ---- doaccess = TRUE; name = fullname; } ! if ((doaccess && access(name, R_OK) != 0) || ! ((fid = open(name, OPEN_MODE)) == -1)) ! { ! if (fullname != NULL) ! free(fullname); return -1; + } + if (fullname != NULL) + free(fullname); + name = NULL; } { struct tzhead * tzhp;
participants (2)
-
ado
-
Earl Chew