Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [obv] Fix crash in c_get_string
@ 2009-04-14 22:02 Jan Kratochvil
  2009-04-14 22:59 ` Thiago Jung Bauermann
  2009-04-15 17:43 ` Tom Tromey
  0 siblings, 2 replies; 4+ messages in thread
From: Jan Kratochvil @ 2009-04-14 22:02 UTC (permalink / raw)
  To: gdb-patches; +Cc: Thiago Jung Bauermann

Hi,

during a failed string read - as when pretty-printing uninitialized
std::string - GDB could crash.

I have a testcase requiring GDB pretty-printing which is not in FSF GDB now so
the test should get in later.  Did not check how to reproduce it more easily.

Checked-in as: http://sourceware.org/ml/gdb-cvs/2009-04/msg00077.html

Original bugreport at: https://bugzilla.redhat.com/show_bug.cgi?id=495781

read_string comment:
   Unless an exception is thrown, BUFFER will always be allocated, even on 
   failure.


Regards,
Jan


gdb/
2009-04-14  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* c-lang.c (c_get_string): Fix xfree crash on a failed string read.

--- src/gdb/c-lang.c	2009/03/21 00:46:17	1.63
+++ src/gdb/c-lang.c	2009/04/14 21:54:33	1.64
@@ -657,7 +657,7 @@
 			 buffer, length);
       if (err)
 	{
-	  xfree (buffer);
+	  xfree (*buffer);
 	  error (_("Error reading string from inferior: %s"),
 		 safe_strerror (err));
 	}


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [obv] Fix crash in c_get_string
  2009-04-14 22:02 [obv] Fix crash in c_get_string Jan Kratochvil
@ 2009-04-14 22:59 ` Thiago Jung Bauermann
  2009-04-15 17:43 ` Tom Tromey
  1 sibling, 0 replies; 4+ messages in thread
From: Thiago Jung Bauermann @ 2009-04-14 22:59 UTC (permalink / raw)
  To: Jan Kratochvil; +Cc: gdb-patches

El mié, 15-04-2009 a las 00:02 +0200, Jan Kratochvil escribió:
> during a failed string read - as when pretty-printing uninitialized
> std::string - GDB could crash.

Thanks for fixing this!
-- 
[]'s
Thiago Jung Bauermann
IBM Linux Technology Center


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [obv] Fix crash in c_get_string
  2009-04-14 22:02 [obv] Fix crash in c_get_string Jan Kratochvil
  2009-04-14 22:59 ` Thiago Jung Bauermann
@ 2009-04-15 17:43 ` Tom Tromey
  2009-04-15 17:53   ` Jan Kratochvil
  1 sibling, 1 reply; 4+ messages in thread
From: Tom Tromey @ 2009-04-15 17:43 UTC (permalink / raw)
  To: Jan Kratochvil; +Cc: gdb-patches, Thiago Jung Bauermann

>>>>> "Jan" == Jan Kratochvil <jan.kratochvil@redhat.com> writes:

Jan> during a failed string read - as when pretty-printing
Jan> uninitialized std::string - GDB could crash.

Thanks, Jan.

Jan> I have a testcase requiring GDB pretty-printing which is not in
Jan> FSF GDB now so the test should get in later.  Did not check how
Jan> to reproduce it more easily.

I made a note to pull this patch in after the pretty-printing series
goes in.  If you'd rather, though, you can do it :-)

Tom


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [obv] Fix crash in c_get_string
  2009-04-15 17:43 ` Tom Tromey
@ 2009-04-15 17:53   ` Jan Kratochvil
  0 siblings, 0 replies; 4+ messages in thread
From: Jan Kratochvil @ 2009-04-15 17:53 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches, Thiago Jung Bauermann

On Wed, 15 Apr 2009 19:43:26 +0200, Tom Tromey wrote:
> Jan> I have a testcase requiring GDB pretty-printing which is not in
> Jan> FSF GDB now so the test should get in later.

It has been posted + checked-in Archer at:
http://sourceware.org/ml/archer/2009-q2/msg00049.html

> Did not check how
> Jan> to reproduce it more easily.
> 
> I made a note to pull this patch in after the pretty-printing series
> goes in.  If you'd rather, though, you can do it :-)

No.
  (In its current form it requires the pretty-printing patches to be in to
  work.  So unaware how I could do it before pretty-printing patches get
  accepted for FSF GDB without rewriting the testcase to no longer be based on
  the pretty-printing support.)

Anyway I do not think the testcase is relevant to the fix, it was just
a contribution to have larger testing codebase for various cornercases.


Regards,
Jan


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2009-04-15 17:53 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-04-14 22:02 [obv] Fix crash in c_get_string Jan Kratochvil
2009-04-14 22:59 ` Thiago Jung Bauermann
2009-04-15 17:43 ` Tom Tromey
2009-04-15 17:53   ` Jan Kratochvil

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox