[PATCH] gdb: check for empty strings in get_standard_cache_dir/get_standard_config_dir

Simon Marchi simon.marchi@efficios.com
Thu Jan 7 21:53:10 GMT 2021



On 2021-01-07 4:43 p.m., Lancelot SIX wrote:
> Hi
>> Ok, I can try this as a follow-up patch, check that the path
>> is absolute using the IS_ABSOLUTE_PATH macro.  Is a tilde path
>> considered absolute? Like
>>
>>    ~/my-cache
>>    ~smarchi/my-cache
> I would be tempted to say that it is not (according to https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html it seems it is not).

I wouldn't mind not supporting tilde paths, but since it worked up to now,
it could be seen as a regression by some.

>> I suppose that it is, since it's just a shortcut for
>> /home/smarchi.
> 
> This actually is the most usual pattern, but the home directory of smarchi could be different. The actual answer is in /etc/passwd or accessed via getent:
> 
> $ getent passwd smarchi | awk -F: '{ print $6 }'

Right.  If we want to support it, we would presumably use gdb_tilde_expand,
which uses glob(3), which gets the real user home.

What's annoying though is that glob won't work with non-existent directories.
So if I use

  /home/smarchi/my/non/existent/directory

it is accepted, and these directories will be created.  But I set

  ~/my/non/existent/directory

gdb_tilde_expand will fail.  Perhaps it's just a limitation of gdb_tilde_expand,
and it should be changed to use something else than glob(3) in order to support
non-existent paths.

Simon


More information about the Gdb-patches mailing list