From owner-svn-src-all@freebsd.org Tue May 16 13:27:46 2017 Return-Path: Delivered-To: svn-src-all@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 4FBD5D6CEA7; Tue, 16 May 2017 13:27:46 +0000 (UTC) (envelope-from jonathan@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 07C4FFDC; Tue, 16 May 2017 13:27:45 +0000 (UTC) (envelope-from jonathan@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v4GDRjbR029554; Tue, 16 May 2017 13:27:45 GMT (envelope-from jonathan@FreeBSD.org) Received: (from jonathan@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v4GDRj63029553; Tue, 16 May 2017 13:27:45 GMT (envelope-from jonathan@FreeBSD.org) Message-Id: <201705161327.v4GDRj63029553@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jonathan set sender to jonathan@FreeBSD.org using -f From: Jonathan Anderson Date: Tue, 16 May 2017 13:27:45 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r318352 - 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-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 16 May 2017 13:27:46 -0000 Author: jonathan Date: Tue May 16 13:27:44 2017 New Revision: 318352 URL: https://svnweb.freebsd.org/changeset/base/318352 Log: Rename rtld's parse_libdir to parse_integer. This is a more accurate name, as the integer doesn't have to be a library directory descriptor. It is also a prerequisite for more argument parsing coming in the near future (e.g., parsing explicit binary descriptors). Reviewed by: kib MFC after: 2 weeks Sponsored by: NSERC Modified: head/libexec/rtld-elf/rtld.c Modified: head/libexec/rtld-elf/rtld.c ============================================================================== --- head/libexec/rtld-elf/rtld.c Tue May 16 11:52:27 2017 (r318351) +++ head/libexec/rtld-elf/rtld.c Tue May 16 13:27:44 2017 (r318352) @@ -115,7 +115,7 @@ static void objlist_push_head(Objlist *, static void objlist_push_tail(Objlist *, Obj_Entry *); static void objlist_put_after(Objlist *, Obj_Entry *, Obj_Entry *); static void objlist_remove(Objlist *, Obj_Entry *); -static int parse_libdir(const char *); +static int parse_integer(const char *); static void *path_enumerate(const char *, path_enum_proc, void *); static void release_object(Obj_Entry *); static int relocate_object_dag(Obj_Entry *root, bool bind_now, @@ -3033,9 +3033,12 @@ search_library_pathfds(const char *name, envcopy = xstrdup(path); for (fdstr = strtok_r(envcopy, ":", &last_token); fdstr != NULL; fdstr = strtok_r(NULL, ":", &last_token)) { - dirfd = parse_libdir(fdstr); - if (dirfd < 0) + dirfd = parse_integer(fdstr); + if (dirfd < 0) { + _rtld_error("failed to parse directory FD: '%s'", + fdstr); break; + } fd = __sys_openat(dirfd, name, O_RDONLY | O_CLOEXEC | O_VERIFY); if (fd >= 0) { *fdp = fd; @@ -5236,29 +5239,27 @@ symlook_init_from_req(SymLook *dst, cons * Parse a file descriptor number without pulling in more of libc (e.g. atoi). */ static int -parse_libdir(const char *str) +parse_integer(const char *str) { static const int RADIX = 10; /* XXXJA: possibly support hex? */ const char *orig; - int fd; + int n; char c; orig = str; - fd = 0; + n = 0; for (c = *str; c != '\0'; c = *++str) { if (c < '0' || c > '9') return (-1); - fd *= RADIX; - fd += c - '0'; + n *= RADIX; + n += c - '0'; } /* Make sure we actually parsed something. */ - if (str == orig) { - _rtld_error("failed to parse directory FD from '%s'", str); + if (str == orig) return (-1); - } - return (fd); + return (n); } /*