Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 15 Jul 2016 19:07:00 +0000 (UTC)
From:      Bryan Drewery <bdrewery@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r302908 - head/libexec/rtld-elf
Message-ID:  <201607151907.u6FJ70PP081936@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: bdrewery
Date: Fri Jul 15 19:07:00 2016
New Revision: 302908
URL: https://svnweb.freebsd.org/changeset/base/302908

Log:
  Fix dlsym(RTLD_NEXT) handling to only return the next library in last library cases.
  
  The root of the problem here is that TAILQ_FOREACH_FROM will default to
  the head of the list if passed NULL, which will be the case if there are
  no libraries loaded after this one.  Thus all libraries, including the
  current, were iterated in that case rather than none.
  
  This was broken in r294373.
  
  Reviewed by:	markj (earlier version), cem, kib, ngie
  MFC after:	1 week
  Sponsored by:	EMC / Isilon Storage Division
  Differential Revision:	https://reviews.freebsd.org/D7216

Modified:
  head/libexec/rtld-elf/rtld.c

Modified: head/libexec/rtld-elf/rtld.c
==============================================================================
--- head/libexec/rtld-elf/rtld.c	Fri Jul 15 17:40:34 2016	(r302907)
+++ head/libexec/rtld-elf/rtld.c	Fri Jul 15 19:07:00 2016	(r302908)
@@ -3291,7 +3291,7 @@ do_dlsym(void *handle, const char *name,
 		   handle == RTLD_SELF) { /* ... caller included */
 	    if (handle == RTLD_NEXT)
 		obj = globallist_next(obj);
-	    TAILQ_FOREACH_FROM(obj, &obj_list, next) {
+	    for (; obj != NULL; obj = TAILQ_NEXT(obj, next)) {
 		if (obj->marker)
 		    continue;
 		res = symlook_obj(&req, obj);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201607151907.u6FJ70PP081936>