This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
RE: [RFA] Avoid calling stat with empty name in relocate_gdb_directory
- From: "Pierre Muller" <pierre dot muller at ics-cnrs dot unistra dot fr>
- To: "'Tom Tromey'" <tromey at redhat dot com>
- Cc: <gdb-patches at sourceware dot org>
- Date: Fri, 14 Dec 2012 09:16:50 +0100
- Subject: RE: [RFA] Avoid calling stat with empty name in relocate_gdb_directory
- References: <29503.7594777115$1354726985@news.gmane.org> <87sj7ks7g6.fsf@fleche.redhat.com> <434.327257289802$1354751122@news.gmane.org> <87d2ynxc6t.fsf@fleche.redhat.com>
> -----Message d'origine-----
> De?: gdb-patches-owner@sourceware.org [mailto:gdb-patches-
> owner@sourceware.org] De la part de Tom Tromey
> Envoyé?: jeudi 6 décembre 2012 19:34
> À?: Pierre Muller
> Cc?: gdb-patches@sourceware.org
> Objet?: Re: [RFA] Avoid calling stat with empty name in
> relocate_gdb_directory
>
> >>>>> "Pierre" == Pierre Muller <pierre.muller@ics-cnrs.unistra.fr>
writes:
>
> Pierre> Apparently it isn't used elsewhere...
> Pierre> Should we modify the default value to NULL instead of ""?
> Pierre> I do not master complicated autoconf things like
> Pierre> GDB_AC_DEFINE_RELOCATABLE well enough to know if this is
> Pierre> without problems...
>
> Pierre> Tell me if you think we should modify it at configury level or
> Pierre> if I should commit my patch, whatever you prefer!
>
> Maybe we should just skip computing gdb_sysroot if TARGET_SYSTEM_ROOT is
> "". What do you think?
I looked at the different calls to relocate_gdb_directory:
$ find . -iname "*.[chy]" |xargs grep -n gdb_directory
./charset.c:816: char *iconv_dir = relocate_gdb_directory (ICONV_BIN,
./defs.h:275:extern char *relocate_gdb_directory (const char *initial, int
flag);
./jit.c:1402: jit_reader_dir = relocate_gdb_directory (JIT_READER_DIR,
./main.c:120:relocate_gdb_directory (const char *initial, int flag)
./main.c:391: gdb_sysroot = relocate_gdb_directory (TARGET_SYSTEM_ROOT,
./main.c:394: debug_file_directory = relocate_gdb_directory (DEBUGDIR,
./main.c:397: gdb_datadir = relocate_gdb_directory (GDB_DATADIR,
./main.c:405: python_libdir = relocate_gdb_directory (tmp,
PYTHON_PATH_RELOCATABLE);
Are we sure all other calls have non-empty first argument?
Another problem is that currently the returned string is
always allocated, which means that we should at least
also use xstrdup ("") ...
I still think that the approach of testing if *dir == '\0'
is safer...
Pierre