This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
Re: vfprintf_maybe_filtered should check vasprintf return value
- To: Eirik Fuller <eirik at netapp dot com>
- Subject: Re: vfprintf_maybe_filtered should check vasprintf return value
- From: Andrew Cagney <ac131313 at cygnus dot com>
- Date: Tue, 26 Sep 2000 18:50:35 -0400
- Cc: gdb-patches at sourceware dot cygnus dot com
- References: <39C17C60.3125D2C0@netapp.com>
Eirik Fuller wrote:
>
> In gdb-5.0 (and, as far as I can tell, later versions of gdb), the
> return value of vasprintf is not checked by vfprintf_maybe_filtered.
> I've found at least one crash which can result from this; if I try
>
> printf "%ls\n", version
>
> on gdb's own symbol table, I get a segfault because linebuffer is
> unchanged by vasprintf, on a Debian GNU/Linux system with the
> vasprintf provided by glibc-2.1.3.
What is causing the call to fail? A dud malloc() normally leads to a
NULL value.
If vasprintf() in glibc-2.1.3 is broken then, perhaphs we should use the
libiberty version.
The gdb/TODO file suggests adding the functions xasprintf() /
xvasprintf() to address this problem.
> With the enclosed patch, I get an error message instead of a crash.
> I make no claims about the optimality of the error message, but I
> believe the patch is fundamentally sound. Please let me know if
> the crash isn't easily repeatable (it is for me), or if any further
> information is required.
It should probably call internal_error() or just use xvasprintf().
sorry for all the questions,
Andrew