From aef0332e316c8c5be3f109a932399834eaaecde1 Mon Sep 17 00:00:00 2001 From: christos Date: Tue, 6 Aug 2013 05:48:39 +0000 Subject: [PATCH] CID 1060853: Negative array index read (REVERSE_NEGATIVE) --- lib/libc/time/zic.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/libc/time/zic.c b/lib/libc/time/zic.c index eb349674975f..a7ee0df1b1e5 100644 --- a/lib/libc/time/zic.c +++ b/lib/libc/time/zic.c @@ -1,4 +1,4 @@ -/* $NetBSD: zic.c,v 1.41 2013/07/17 20:13:04 christos Exp $ */ +/* $NetBSD: zic.c,v 1.42 2013/08/06 05:48:39 christos Exp $ */ /* ** This file is in the public domain, so clarified as of ** 2006-07-17 by Arthur David Olson. @@ -10,7 +10,7 @@ #include #ifndef lint -__RCSID("$NetBSD: zic.c,v 1.41 2013/07/17 20:13:04 christos Exp $"); +__RCSID("$NetBSD: zic.c,v 1.42 2013/08/06 05:48:39 christos Exp $"); #endif /* !defined lint */ #include "version.h" @@ -1572,10 +1572,13 @@ writezone(const char *const name, const char *const string) int mrudst, mrustd, hidst, histd, type; hidst = histd = mrudst = mrustd = -1; - for (i = thistimei; i < thistimelim; ++i) + for (i = thistimei; i < thistimelim; ++i) { + if (i < 0) + continue; if (isdsts[types[i]]) mrudst = types[i]; else mrustd = types[i]; + } for (i = 0; i < typecnt; ++i) if (writetype[i]) { if (isdsts[i])