[tz] [PROPOSED PATCH 2/9] zdump: don't use uninitialized storage

Paul Eggert eggert at cs.ucla.edu
Mon Aug 25 06:59:46 UTC 2014


* zdump.c (main): Avoid use of uninitalized locals in rare cases.
* NEWS: Mention this.
---
 NEWS    | 4 ++--
 zdump.c | 4 +++-
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/NEWS b/NEWS
index 2994afd..a14929b 100644
--- a/NEWS
+++ b/NEWS
@@ -41,8 +41,8 @@ Unreleased, experimental changes
 
   Changes affecting code
 
-    Some crashes have been fixed when the tz library is given a
-    compiled time zone file containing invalid or outlandish data.
+    Some crashes have been fixed when zdump or the tz library is given
+    invalid or outlandish input.
 
     The tz library no longer mishandles leap seconds on platforms with
     unsigned time_t in time zones that lack ordinary transitions after 1970.
diff --git a/zdump.c b/zdump.c
index 9eb434e..3dde5e8 100644
--- a/zdump.c
+++ b/zdump.c
@@ -420,8 +420,11 @@ _("%s: usage: %s [--version] [--help] [-{vV}] [-{ct} [lo,]hi] zonename ...\n"
 int
 main(int argc, char *argv[])
 {
+	/* These are static so that they're initially zero.  */
 	static char *		abbrev;
 	static size_t		abbrevsize;
+	static struct tm	newtm;
+
 	register int		i;
 	register bool		vflag;
 	register bool		Vflag;
@@ -433,7 +436,6 @@ main(int argc, char *argv[])
 	time_t			t;
 	time_t			newt;
 	struct tm		tm;
-	struct tm		newtm;
 	register struct tm *	tmp;
 	register struct tm *	newtmp;
 
-- 
1.9.1



More information about the tz mailing list