[Ltrace-devel] glob.c: In function 'globcomp': error: 'regex' may be used uninitialized in this function [-Werror=maybe-uninitialized]
Petr Machata
pmachata at redhat.com
Thu Nov 8 19:32:12 UTC 2012
Sedat Dilek <sedat.dilek at gmail.com> writes:
> Seen with ltrace-git up to commit
> 4754ea02d067a88e87d4cc67500419f20781de39
> ("4754ea02d067a88e87d4cc67500419f20781de39")
> ...
> libtool: compile:
> /home/wearefam/src/freetz/freetz-git/toolchain/build/mipsel_gcc-4.7.2-RC-20120914_uClibc-0.9.33.2/mipsel-linux-uclibc/bin/mipsel-linux-uclibc-gcc
> -DHAVE_CONFIG_H -I. -I./sysdeps/linux-gnu/mipsel -I./sysdeps/linux-gnu
> -I./sysdeps -I. -DSYSCONFDIR=\"/etc\" -Wall -Wsign-compare
> -Wfloat-equal -Wformat-security -Werror -march=4kc -Os -pipe
> -Wa,--trap -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE
> -D_FILE_OFFSET_BITS=64 -MT glob.lo -MD -MP -MF .deps/glob.Tpo -c
> glob.c -fPIC -DPIC -o .libs/glob.o
> glob.c: In function 'globcomp':
> glob.c:190:9: error: 'regex' may be used uninitialized in this
> function [-Werror=maybe-uninitialized]
> cc1: all warnings being treated as errors
> make[3]: *** [glob.lo] Error 1
> make[3]: Leaving directory
> `/home/wearefam/src/freetz/freetz-git/source/target-mipsel_uClibc-0.9.33.2/ltrace-0.7.0-git'
Again, this seem spurious. Regex is initialized in glob_to_regex from
buf, which is itself properly initialized.
There's not even anything that I can reasonably initialize to. Should I
use NULL? Then if it's not overwritten in glob_to_regex, this NULL gets
passed to regcomp, and that SIGSEGVs. So the full fix should look like:
--- a/glob.c
+++ b/glob.c
@@ -183,9 +183,9 @@ glob_to_regex(const char *glob, char **retp)
int
globcomp(regex_t *preg, const char *glob, int cflags)
{
- char *regex;
+ char *regex = NULL;
int status = glob_to_regex(glob, ®ex);
- if (status != 0)
+ if (status != 0 || regex == NULL)
return status;
status = regcomp(preg, regex, cflags);
free(regex);
Frankly, that's just silly. Please update your toolchain. Let's deal
with this (by filing bugs) if golden GCC complains as well.
Thanks,
PM
More information about the Ltrace-devel
mailing list