summaryrefslogtreecommitdiff
path: root/src/third_party/scripts
diff options
context:
space:
mode:
authorBilly Donahue <billy.donahue@mongodb.com>2018-12-21 16:14:11 -0500
committerBilly Donahue <billy.donahue@mongodb.com>2018-12-27 13:02:40 -0500
commitf53ed89cef7c4356789114b2de1a5294e3d7a6f7 (patch)
treec498d9cc98a3186aa5211f10300354d7f4b8fa15 /src/third_party/scripts
parent0d2075bc9362eb5971ec09f2b224baeefe920a18 (diff)
downloadmongo-f53ed89cef7c4356789114b2de1a5294e3d7a6f7.tar.gz
SERVER-36644 remove -Wno-format-truncation
cherry pick https://github.com/derickr/timelib/commit/157caf3f66da49f4df55c532a7d82a5d0aa4be11 into timelib
Diffstat (limited to 'src/third_party/scripts')
-rwxr-xr-xsrc/third_party/scripts/timelib_get_sources.sh66
1 files changed, 66 insertions, 0 deletions
diff --git a/src/third_party/scripts/timelib_get_sources.sh b/src/third_party/scripts/timelib_get_sources.sh
index e09a081c901..3151222f2e8 100755
--- a/src/third_party/scripts/timelib_get_sources.sh
+++ b/src/third_party/scripts/timelib_get_sources.sh
@@ -52,6 +52,72 @@ cp -r $TEMP_DIR/* $DEST_DIR
cd $DEST_DIR
+patch -p1 <<'EOF'
+From 157caf3f66da49f4df55c532a7d82a5d0aa4be11 Mon Sep 17 00:00:00 2001
+From: Derick Rethans <github@derickrethans.nl>
+Date: Fri, 11 May 2018 10:51:02 +0100
+Subject: [PATCH] Fixed #37: Incorrect snprintf invocation with static buffer
+
+---
+ Makefile | 4 ++--
+ parse_zoneinfo.c | 12 ++++++++++--
+ 2 files changed, 12 insertions(+), 4 deletions(-)
+
+diff --git a/Makefile b/Makefile
+index 2094595..b6acd1a 100644
+--- a/Makefile
++++ b/Makefile
+@@ -8,11 +8,11 @@ CFLAGS=-Wdeclaration-after-statement ${FLAGS}
+
+ CPPFLAGS=${FLAGS}
+
+-LDFLAGS=-lm -fsanitize=undefined
++LDFLAGS=-lm -fsanitize=undefined -l:libubsan.so.1
+
+ TEST_LDFLAGS=-lCppUTest
+
+-CC=gcc
++CC=gcc-8
+ MANUAL_TESTS=tests/tester-parse-interval \
+ tests/tester-parse-tz tests/tester-iso-week tests/test-abbr-to-id \
+ tests/enumerate-timezones tests/date_from_isodate
+diff --git a/parse_zoneinfo.c b/parse_zoneinfo.c
+index 654348c..875d756 100644
+--- a/parse_zoneinfo.c
++++ b/parse_zoneinfo.c
+@@ -101,7 +101,8 @@ static int is_valid_tzfile(const struct stat *st, int fd)
+ * length of the mapped data is placed in *length. */
+ static char *read_tzfile(const char *directory, const char *timezone, size_t *length)
+ {
+- char fname[MAXPATHLEN];
++ char *fname;
++ size_t fname_len;
+ char *buffer;
+ struct stat st;
+ int fd;
+@@ -115,9 +116,16 @@ static char *read_tzfile(const char *directory, const char *timezone, size_t *le
+ return NULL;
+ }
+
+- snprintf(fname, sizeof(fname), "%s%s%s", directory, TIMELIB_DIR_SEPARATOR, timezone /* canonical_tzname(timezone) */);
++ fname_len = strlen(directory) + strlen(TIMELIB_DIR_SEPARATOR) + strlen(timezone) + 1;
++ fname = malloc(fname_len);
++ if (snprintf(fname, fname_len, "%s%s%s", directory, TIMELIB_DIR_SEPARATOR, timezone) < 0) {
++ free(fname);
++ return NULL;
++ }
+
+ fd = open(fname, O_RDONLY);
++ free(fname);
++
+ if (fd == -1) {
+ return NULL;
+ } else if (fstat(fd, &st) != 0 || !is_valid_tzfile(&st, fd)) {
+--
+2.17.1
+EOF
+
+
# Prune files
rm -rf $DEST_DIR/tests
rm $DEST_DIT/zones/old-tzcode-32-bit-output.tar.gz || true