minor fixes for tzcode1996o
Todd C. Miller
Todd.Miller at courtesan.com
Thu Jan 16 04:15:10 UTC 1997
This fixes potential buffer overflows, corrects getopt(3) usage
(getopt(3) returns -1, not EOF these days), and adds another
PCTS tweak to pass an arguably bogus test. The diff is reversed,
sorry about that.
- todd
--- time/localtime.c Mon Jan 13 20:17:09 1997
+++ /home/millert/tmp/tzcode1996o/localtime.c Tue Nov 5 11:50:08 1996
@@ -291,10 +276,10 @@
if (name[0] == ':')
++name;
doaccess = name[0] == '/';
if (!doaccess) {
if ((p = TZDIR) == NULL)
return -1;
- if ((strlen(p) + strlen(name) + 2) >= sizeof fullname)
+ if ((strlen(p) + strlen(name) + 1) >= sizeof fullname)
return -1;
(void) strcpy(fullname, p);
(void) strcat(fullname, "/");
@@ -1379,14 +1364,7 @@
dir = tmcomp(&mytm, &yourtm);
if (dir != 0) {
if (bits-- < 0)
-#ifdef PCTS
- {
- t += 2;
- break;
- }
-#else
return WRONG;
-#endif
if (bits < 0)
--t; /* may be needed if new t is minimal */
else if (dir > 0)
--- time/zdump.c Mon Jan 13 20:17:17 1997
+++ /home/millert/tmp/tzcode1996o/zdump.c Tue Nov 5 12:00:05 1996
@@ -224,7 +223,6 @@
show(argv[i], t, TRUE);
tm = *localtime(&t);
(void) strncpy(buf, abbr(&tm), (sizeof buf) - 1);
- buf[(sizeof buf) - 1] = '\0';
for ( ; ; ) {
if (cutoff != NULL && t >= cuttime)
break;
@@ -241,7 +239,6 @@
newtm = *localtime(&newt);
(void) strncpy(buf, abbr(&newtm),
(sizeof buf) - 1);
- buf[(sizeof buf) - 1] = '\0';
}
t = newt;
tm = newtm;
@@ -283,7 +280,6 @@
lotm = *localtime(&lot);
(void) strncpy(loab, abbr(&lotm), (sizeof loab) - 1);
- loab[(sizeof loab) - 1] = '\0';
while ((hit - lot) >= 2) {
t = lot / 2 + hit / 2;
if (t <= lot)
--- time/zic.c Wed Jan 15 16:41:36 1997
+++ /home/millert/tmp/tzcode1996o/zic.c Fri Dec 27 19:42:04 1996
@@ -478,7 +476,7 @@
(void) textdomain(TZ_DOMAIN);
#endif /* HAVE_GETTEXT - 0 */
progname = argv[0];
- while ((c = getopt(argc, argv, "d:l:p:L:vsy:")) != -1)
+ while ((c = getopt(argc, argv, "d:l:p:L:vsy:")) != EOF)
switch (c) {
default:
usage();
More information about the tz
mailing list