public inbox for libc-hacker@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Don't look at freed memory in dl-deps.c
@ 2006-01-18 10:04 Jakub Jelinek
  2006-01-18 19:48 ` Roland McGrath
  0 siblings, 1 reply; 2+ messages in thread
From: Jakub Jelinek @ 2006-01-18 10:04 UTC (permalink / raw)
  To: Ulrich Drepper, Roland McGrath; +Cc: Glibc hackers

Hi!

https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=178159
verified with valgrind on elf/neededtest4.
_dl_catch_error might allocate objname in the same memory block as errstring
(right after its terminating '\0'), so after free ((char *) errstring)
shouldn't be used.  But it is passed down to _dl_signal_error.
  if (errno_reason)
    _dl_signal_error (errno_reason == -1 ? 0 : errno_reason, objname,
                      NULL, errstring);
Fixed by making a local copy, verified with valgrind.

2006-01-18  Jakub Jelinek  <jakub@redhat.com>

	* elf/dl-deps.c (_dl_map_object_deps): In case of failure also make a
	copy of objname string.

--- libc/elf/dl-deps.c.jj	2005-06-22 18:34:11.000000000 +0200
+++ libc/elf/dl-deps.c	2006-01-18 10:28:34.000000000 +0100
@@ -247,6 +247,7 @@ _dl_map_object_deps (struct link_map *ma
 		if (__builtin_expect (errstring != NULL, 0))
 		  {
 		    char *new_errstring = strdupa (errstring);
+		    objname = strdupa (objname);
 		    if (malloced)
 		      free ((char *) errstring);
 		    errstring = new_errstring;
@@ -337,6 +338,7 @@ _dl_map_object_deps (struct link_map *ma
 		    if (__builtin_expect (errstring != NULL, 0))
 		      {
 			char *new_errstring = strdupa (errstring);
+			objname = strdupa (objname);
 			if (malloced)
 			  free ((char *) errstring);
 			errstring = new_errstring;

	Jakub

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

* Re: [PATCH] Don't look at freed memory in dl-deps.c
  2006-01-18 10:04 [PATCH] Don't look at freed memory in dl-deps.c Jakub Jelinek
@ 2006-01-18 19:48 ` Roland McGrath
  0 siblings, 0 replies; 2+ messages in thread
From: Roland McGrath @ 2006-01-18 19:48 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: Ulrich Drepper, Glibc hackers

Applied.

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

end of thread, other threads:[~2006-01-18 19:48 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-01-18 10:04 [PATCH] Don't look at freed memory in dl-deps.c Jakub Jelinek
2006-01-18 19:48 ` Roland McGrath

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).