[syslinux:pathbased] sysdump: guard against a nonsensical month number

syslinux-bot for H. Peter Anvin hpa at zytor.com
Sun Feb 14 14:12:15 PST 2010


Commit-ID:  97a0ccf075ff62f1cf8deafe701e182a60515a8e
Gitweb:     http://syslinux.zytor.com/commit/97a0ccf075ff62f1cf8deafe701e182a60515a8e
Author:     H. Peter Anvin <hpa at zytor.com>
AuthorDate: Sun, 14 Feb 2010 14:11:15 -0800
Committer:  H. Peter Anvin <hpa at zytor.com>
CommitDate: Sun, 14 Feb 2010 14:11:15 -0800

sysdump: guard against a nonsensical month number

If the month is off the table, don't even try to read it...

Signed-off-by: H. Peter Anvin <hpa at zytor.com>


---
 com32/sysdump/ctime.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/com32/sysdump/ctime.c b/com32/sysdump/ctime.c
index 5af8566..56c8efb 100644
--- a/com32/sysdump/ctime.c
+++ b/com32/sysdump/ctime.c
@@ -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;



More information about the Syslinux-commits mailing list