bug-gettext
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: UBSan findings in GetText 0.20.1


From: Jeffrey Walton
Subject: Re: UBSan findings in GetText 0.20.1
Date: Wed, 29 Jan 2020 23:02:24 -0500

On Wed, Jan 29, 2020 at 7:43 PM Jeffrey Walton <address@hidden> wrote:
>
> I'm building GetText 0.20.1 with UBsan and then running self-tests.
> The UBsan flags are -fsanitize=undefined -fno-sanitize-recover. I'm
> seeing four failures that don't show up under normal testing:
>
> make[5]: Entering directory
> '/home/jwalton/Build-Scripts/gettext-0.20.1/gettext-tools/tests'
> ...
> FAIL: msgattrib-properties-1
> ...
> FAIL: msgexec-3
> ...
> FAIL: msgfilter-3
> ...
> FAIL: msguniq-4
> ...

The patch below clears the issue.

It should also avoid a crash when the runtime library is Musl. Musl is
less forgiving then glibc. The Musl folks prefer the crash so the
program gets fixed.

--- gettext-tools/src/read-properties.c
+++ gettext-tools/src/read-properties.c
@@ -582,7 +582,8 @@
   /* Return the result.  */
   {
     unsigned char *utf8_string = XNMALLOC (utf8_buflen + 1, unsigned char);
-    memcpy (utf8_string, utf8_buffer, utf8_buflen);
+    if (utf8_buffer)
+      memcpy (utf8_string, utf8_buffer, utf8_buflen);
     utf8_string[utf8_buflen] = '\0';

     return (char *) utf8_string;

Jeff



reply via email to

[Prev in Thread] Current Thread [Next in Thread]