summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaiki Ueno <ueno@gnu.org>2015-01-24 16:51:18 +0900
committerDaiki Ueno <ueno@gnu.org>2015-01-24 16:51:18 +0900
commit2d36f1e1de7521090272b88f161711f95228c19d (patch)
treea61483b83f94b00cc84c5731541bf756ad6aa236
parent6d9af7f94e0057df99a99652df713e6d14138aa5 (diff)
downloadexternal_gettext-2d36f1e1de7521090272b88f161711f95228c19d.zip
external_gettext-2d36f1e1de7521090272b88f161711f95228c19d.tar.gz
external_gettext-2d36f1e1de7521090272b88f161711f95228c19d.tar.bz2
xgettext, msgmerge: Avoid undefined non-null argument behavior
* xgettext.c (remember_a_message): Building with gcc's -fsanitize=undefined and running tests triggered: xgettext.c:2425:17: runtime error: null pointer passed as argument \ 2, which is declared to never be null Adjust the argument of strncmp to never be null. * msgmerge.c (message_merge): Likewise for memcpy.
-rw-r--r--gettext-tools/src/ChangeLog10
-rw-r--r--gettext-tools/src/msgmerge.c5
-rw-r--r--gettext-tools/src/xgettext.c2
3 files changed, 14 insertions, 3 deletions
diff --git a/gettext-tools/src/ChangeLog b/gettext-tools/src/ChangeLog
index d0ad21f..af08eda 100644
--- a/gettext-tools/src/ChangeLog
+++ b/gettext-tools/src/ChangeLog
@@ -1,3 +1,13 @@
+2015-01-24 Daiki Ueno <ueno@gnu.org>
+
+ xgettext, msgmerge: Avoid undefined non-null argument behavior
+ * xgettext.c (remember_a_message): Building with gcc's
+ -fsanitize=undefined and running tests triggered:
+ xgettext.c:2425:17: runtime error: null pointer passed as argument \
+ 2, which is declared to never be null
+ Adjust the argument of strncmp to never be null.
+ * msgmerge.c (message_merge): Likewise for memcpy.
+
2015-01-23 Daiki Ueno <ueno@gnu.org>
build: Fix parallel build from git checkout
diff --git a/gettext-tools/src/msgmerge.c b/gettext-tools/src/msgmerge.c
index d8e02ae..0415b2a 100644
--- a/gettext-tools/src/msgmerge.c
+++ b/gettext-tools/src/msgmerge.c
@@ -1025,8 +1025,9 @@ message_merge (message_ty *def, message_ty *ref, bool force_fuzzy,
char *extended =
(char *) obstack_alloc (&pool,
header_fields[UNKNOWN].len + len + 1);
- memcpy (extended, header_fields[UNKNOWN].string,
- header_fields[UNKNOWN].len);
+ if (header_fields[UNKNOWN].string)
+ memcpy (extended, header_fields[UNKNOWN].string,
+ header_fields[UNKNOWN].len);
memcpy (&extended[header_fields[UNKNOWN].len], cp, len);
extended[header_fields[UNKNOWN].len + len] = '\0';
header_fields[UNKNOWN].string = extended;
diff --git a/gettext-tools/src/xgettext.c b/gettext-tools/src/xgettext.c
index 28d28a0..f9156eb 100644
--- a/gettext-tools/src/xgettext.c
+++ b/gettext-tools/src/xgettext.c
@@ -2327,7 +2327,7 @@ meta information, not the empty string.\n")));
/* The string before the comment tag. For example, If "** TRANSLATORS:"
is seen and the comment tag is "TRANSLATORS:",
then comment_tag_prefix is set to "** ". */
- const char *comment_tag_prefix = NULL;
+ const char *comment_tag_prefix = "";
size_t comment_tag_prefix_length = 0;
nitems_before = (mp->comment_dot != NULL ? mp->comment_dot->nitems : 0);