buffer overflow, day fencepost
authorKeith Bostic <bostic@ucbvax.Berkeley.EDU>
Tue, 28 Mar 1989 00:36:52 +0000 (16:36 -0800)
committerKeith Bostic <bostic@ucbvax.Berkeley.EDU>
Tue, 28 Mar 1989 00:36:52 +0000 (16:36 -0800)
SCCS-vsn: usr.bin/chpass/util.c 5.9

usr/src/usr.bin/chpass/util.c

index 9053e50..81a3a2b 100644 (file)
@@ -16,7 +16,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)util.c     5.8 (Berkeley) %G%";
+static char sccsid[] = "@(#)util.c     5.9 (Berkeley) %G%";
 #endif /* not lint */
 
 #include <sys/types.h>
 #endif /* not lint */
 
 #include <sys/types.h>
@@ -40,7 +40,7 @@ ttoa(tval)
        time_t tval;
 {
        struct tm *tp;
        time_t tval;
 {
        struct tm *tp;
-       static char tbuf[10];
+       static char tbuf[50];
 
        if (tval) {
                tp = localtime(&tval);
 
        if (tval) {
                tp = localtime(&tval);
@@ -98,7 +98,7 @@ bad:          return(1);
                    DAYSPERLYEAR : DAYSPERNYEAR;
        while (--month)
                tval += dmsize[month];
                    DAYSPERLYEAR : DAYSPERNYEAR;
        while (--month)
                tval += dmsize[month];
-       tval += day - 1;
+       tval += day;
        tval = tval * HOURSPERDAY * MINSPERHOUR * SECSPERMIN;
        tval -= lt->tm_gmtoff;
        *store = tval;
        tval = tval * HOURSPERDAY * MINSPERHOUR * SECSPERMIN;
        tval -= lt->tm_gmtoff;
        *store = tval;