sysdump: guard against a nonsensical month number
authorH. Peter Anvin <hpa@zytor.com>
Sun, 14 Feb 2010 22:11:15 +0000 (14:11 -0800)
committerH. Peter Anvin <hpa@zytor.com>
Sun, 14 Feb 2010 22:11:15 +0000 (14:11 -0800)
If the month is off the table, don't even try to read it...

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
com32/sysdump/ctime.c

index 5af8566..56c8efb 100644 (file)
@@ -58,6 +58,13 @@ uint32_t posix_time(void)
        mo += 12;
     }
 
+    /*
+     * Just in case: if the month is nonsense, don't read off the end
+     * of the table...
+     */
+    if (mo-3 > 11)
+       return 0;
+
     t = y*365 + y/4 - y/100 + y/400 + yday[mo-3] + d - 719469;
     t *= 24;
     t += h;