tzdata/backport-Fail-on-ZIC_BLOAT_DEFAULT-typo.patch

49 lines
1.6 KiB
Diff
Raw Normal View History

From 103e7868cf8fa91146c1b46012650a16ce29f9b0 Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
Date: Sun, 18 Oct 2020 13:34:30 -0700
Subject: [PATCH 5/6] Fail on ZIC_BLOAT_DEFAULT typo
Also, try to pacify Coverity. Problem reported by Tom Lane in:
https://mm.icann.org/pipermail/tz/2020-October/029370.html
* zic.c (main): Use a static constant to try to pacify Coverity.
Also, check that the default is either "slim" or "fat".
---
zic.c | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/zic.c b/zic.c
index a47c052..a902b34 100644
--- a/zic.c
+++ b/zic.c
@@ -658,7 +658,8 @@ static const char * leapsec;
static const char * tzdefault;
/* -1 if the TZif output file should be slim, 0 if default, 1 if the
- output should be fat for backward compatibility. The default is slim. */
+ output should be fat for backward compatibility. ZIC_BLOAT_DEFAULT
+ determines the default. */
static int bloat;
static bool
@@ -795,8 +796,15 @@ _("%s: invalid time range: %s\n"),
}
if (optind == argc - 1 && strcmp(argv[optind], "=") == 0)
usage(stderr, EXIT_FAILURE); /* usage message by request */
- if (bloat == 0)
- bloat = strcmp(ZIC_BLOAT_DEFAULT, "slim") == 0 ? -1 : 1;
+ if (bloat == 0) {
+ static char const bloat_default[] = ZIC_BLOAT_DEFAULT;
+ if (strcmp(bloat_default, "slim") == 0)
+ bloat = -1;
+ else if (strcmp(bloat_default, "fat") == 0)
+ bloat = 1;
+ else
+ abort(); /* Configuration error. */
+ }
if (directory == NULL)
directory = TZDIR;
if (tzdefault == NULL)
--
1.8.3.1