[commited] small changes to fix hpux-cc compile

Randolph Chung randolph@tausq.org
Sun May 16 17:21:00 GMT 2004


> So what happens if your hardcoded auto array of size 4 ever overflows?
> We get a nasty bit of stack corruption.  I hate seeing code like this
> creep into gdb.  It works until something else changes and then it
> quietly crashes or prints random bad results.

ok, how about like this then? this is consistent with how __dld_flags
isused in other parts of somsolib.c

2004-05-16  Randolph Chung  <tausq@debian.org>

	* somsolib.c (som_solib_remove_inferior_hook): Make all the size
	references to dld_flags_buffer consistent.

Index: somsolib.c
===================================================================
RCS file: /cvs/src/src/gdb/somsolib.c,v
retrieving revision 1.33
diff -u -p -r1.33 somsolib.c
--- somsolib.c	16 May 2004 04:33:41 -0000	1.33
+++ somsolib.c	16 May 2004 17:19:04 -0000
@@ -1081,16 +1081,13 @@ som_solib_remove_inferior_hook (int pid)
   msymbol = lookup_minimal_symbol ("__dld_flags", NULL, NULL);
 
   addr = SYMBOL_VALUE_ADDRESS (msymbol);
-  status = target_read_memory (addr, dld_flags_buffer, TARGET_INT_BIT / TARGET_CHAR_BIT);
+  status = target_read_memory (addr, dld_flags_buffer, 4);
 
-  dld_flags_value = extract_unsigned_integer (dld_flags_buffer,
-					      sizeof (dld_flags_value));
+  dld_flags_value = extract_unsigned_integer (dld_flags_buffer, 4);
 
   dld_flags_value &= ~DLD_FLAGS_HOOKVALID;
-  store_unsigned_integer (dld_flags_buffer,
-			  sizeof (dld_flags_value),
-			  dld_flags_value);
-  status = target_write_memory (addr, dld_flags_buffer, TARGET_INT_BIT / TARGET_CHAR_BIT);
+  store_unsigned_integer (dld_flags_buffer, 4, dld_flags_value);
+  status = target_write_memory (addr, dld_flags_buffer, 4);
 
   do_cleanups (old_cleanups);
 }

-- 
Randolph Chung
Debian GNU/Linux Developer, hppa/ia64 ports
http://www.tausq.org/



More information about the Gdb-patches mailing list