This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH] Guard against 'current_directory == NULL' on gdb_abspath (PR gdb/23613)
- From: Sergio Durigan Junior <sergiodj at redhat dot com>
- To: Tom Tromey <tom at tromey dot com>
- Cc: GDB Patches <gdb-patches at sourceware dot org>
- Date: Thu, 11 Jul 2019 21:21:00 -0400
- Subject: Re: [PATCH] Guard against 'current_directory == NULL' on gdb_abspath (PR gdb/23613)
- References: <20190710234615.14800-1-sergiodj@redhat.com> <87h87sblqg.fsf@tromey.com>
Thanks for the review, Tom.
On Thursday, July 11 2019, Tom Tromey wrote:
>>>>>> "Sergio" == Sergio Durigan Junior <sergiodj@redhat.com> writes:
>
> Sergio> So I fixed the problem with the patch below. The idea is that, if
> Sergio> 'current_directory' is NULL, then the final string returned should be
> Sergio> just the "path".
>
> I found other spots relying on current_directory in this way, so I
> wonder if this is the best approach.
>
> For example, corelow.c:
>
> gdb::unique_xmalloc_ptr<char> filename (tilde_expand (arg));
> if (!IS_ABSOLUTE_PATH (filename.get ()))
> filename.reset (concat (current_directory, "/",
> filename.get (), (char *) NULL));
>
> I guess this should just be converted to gdb_abspath?
Yeah, agreed, this is doing the same thing that gdb_abspath does, but
without the proper checks.
> ... but also code in source.c and some other spots.
I will make sure to grep for "current_directory" and adjust the code
where it's necessary.
> If this approach is the right one -- and it seems like it could be --
> then the function documentation should at least be updated to reflect
> this error case.
I'll do that as well, good idea.
As I mentioned on IRC, I think this is the best solution we have for
now. It's really not possible to do much without a current directory
here.
I'll send v2 soon. Thanks,
--
Sergio
GPG key ID: 237A 54B1 0287 28BF 00EF 31F4 D0EB 7628 65FC 5E36
Please send encrypted e-mail if possible
http://sergiodj.net/