From: Bruno Haible Date: Wed, 10 Apr 2019 21:49:09 +0000 (+0200) Subject: msgfmt: Fix a buffer overrun. X-Git-Tag: v0.20~62 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bf385f1488f7b6effc3ffe2d668e7e0b5f621ab4;p=thirdparty%2Fgettext.git msgfmt: Fix a buffer overrun. Reported by Tobi Schäfer at , via Ryan Schmidt <@ryandesign.com> at . Patch proposed by Joshua Root. * gettext-tools/src/write-java.c (msgid_hashcode): Allocate memory for the trailing NUL byte as well. --- diff --git a/gettext-tools/src/write-java.c b/gettext-tools/src/write-java.c index 07e9f76d9..08ff853bb 100644 --- a/gettext-tools/src/write-java.c +++ b/gettext-tools/src/write-java.c @@ -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);