]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
xgettext, msgmerge: Avoid undefined non-null argument behavior
authorDaiki Ueno <ueno@gnu.org>
Sat, 24 Jan 2015 07:51:18 +0000 (16:51 +0900)
committerDaiki Ueno <ueno@gnu.org>
Sat, 24 Jan 2015 07:51:18 +0000 (16:51 +0900)
* 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.

gettext-tools/src/ChangeLog
gettext-tools/src/msgmerge.c
gettext-tools/src/xgettext.c

index d0ad21fbc170ca81bf0b4c5a9da138ca06380370..af08eda8b070e49bb0635ae10f4ed15254c26d45 100644 (file)
@@ -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
index d8e02ae1060e4850988ec825168ea1d64bccd140..0415b2ac2c7e96abf1fca248f2d7869b591b6311 100644 (file)
@@ -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;
index 28d28a0a8d2fd0c64bd517868c1be4f5a193ee6c..f9156ebf9e9766cf46a76e5b8f142553458f32d1 100644 (file)
@@ -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);