From owner-svn-src-head@freebsd.org Fri Jul 15 19:07:01 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 8F738B9A83E; Fri, 15 Jul 2016 19:07:01 +0000 (UTC) (envelope-from bdrewery@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 53C671606; Fri, 15 Jul 2016 19:07:01 +0000 (UTC) (envelope-from bdrewery@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u6FJ70Au081937; Fri, 15 Jul 2016 19:07:00 GMT (envelope-from bdrewery@FreeBSD.org) Received: (from bdrewery@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u6FJ70PP081936; Fri, 15 Jul 2016 19:07:00 GMT (envelope-from bdrewery@FreeBSD.org) Message-Id: <201607151907.u6FJ70PP081936@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bdrewery set sender to bdrewery@FreeBSD.org using -f From: Bryan Drewery Date: Fri, 15 Jul 2016 19:07:00 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r302908 - head/libexec/rtld-elf X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 15 Jul 2016 19:07:01 -0000 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);