]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
msgfmt: Fix a buffer overrun.
authorBruno Haible <bruno@clisp.org>
Wed, 10 Apr 2019 21:49:09 +0000 (23:49 +0200)
committerBruno Haible <bruno@clisp.org>
Wed, 10 Apr 2019 21:49:09 +0000 (23:49 +0200)
Reported by Tobi Schäfer at <https://trac.macports.org/ticket/58323>,
via Ryan Schmidt <@ryandesign.com> at <https://savannah.gnu.org/bugs/?56112>.
Patch proposed by Joshua Root.

* gettext-tools/src/write-java.c (msgid_hashcode): Allocate memory for the
trailing NUL byte as well.

gettext-tools/src/write-java.c

index 07e9f76d980a50148ad18c5531b2289a4d7a7365..08ff853bb687191f3119d1f91c2de0487ea22b0a 100644 (file)
@@ -151,7 +151,7 @@ msgid_hashcode (const char *msgctxt, const char *msgid)
       char *combined;
       unsigned int result;
 
-      combined = (char *) xmalloca (combined_len);
+      combined = (char *) xmalloca (combined_len + 1);
       memcpy (combined, msgctxt, msgctxt_len);
       combined[msgctxt_len] = MSGCTXT_SEPARATOR;
       memcpy (combined + msgctxt_len + 1, msgid, msgid_len + 1);