strcpy to a NULL pointer is bad.
authorAlan T. DeKok <aland@freeradius.org>
Mon, 2 Aug 2010 06:41:34 +0000 (08:41 +0200)
committerAlan T. DeKok <aland@freeradius.org>
Mon, 2 Aug 2010 13:31:28 +0000 (15:31 +0200)
Closes bug #98

src/lib/valuepair.c

index 9b9e94c..efe37db 100644 (file)
@@ -808,13 +808,11 @@ static int gettime(const char *valstr, time_t *date)
                f[2] = strchr(f[1], ':'); /* find : separator */
                if (f[2]) {
                  *(f[2]++) = '\0';     /* nuke it, and point to SS */
-               } else {
-                 strcpy(f[2], "0");    /* assignment would discard const */
-               }
+                 tm->tm_sec = atoi(f[2]);
+               }                       /* else leave it as zero */
 
                tm->tm_hour = atoi(f[0]);
                tm->tm_min = atoi(f[1]);
-               tm->tm_sec = atoi(f[2]);
        }
 
        /*