From owner-svn-src-all@freebsd.org Tue Nov 21 07:35:31 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 3C84EDE5FFC; Tue, 21 Nov 2017 07:35:31 +0000 (UTC) (envelope-from imp@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 08FC93D58; Tue, 21 Nov 2017 07:35:30 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id vAL7ZUZL030025; Tue, 21 Nov 2017 07:35:30 GMT (envelope-from imp@FreeBSD.org) Received: (from imp@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id vAL7ZULl030024; Tue, 21 Nov 2017 07:35:30 GMT (envelope-from imp@FreeBSD.org) Message-Id: <201711210735.vAL7ZULl030024@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: imp set sender to imp@FreeBSD.org using -f From: Warner Losh Date: Tue, 21 Nov 2017 07:35:30 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r326051 - head/usr.sbin/efidp X-SVN-Group: head X-SVN-Commit-Author: imp X-SVN-Commit-Paths: head/usr.sbin/efidp X-SVN-Commit-Revision: 326051 X-SVN-Commit-Repository: base 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.25 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, 21 Nov 2017 07:35:31 -0000 Author: imp Date: Tue Nov 21 07:35:29 2017 New Revision: 326051 URL: https://svnweb.freebsd.org/changeset/base/326051 Log: This program is more useful if it skips leading whitespace when parsing a textual UEFI Device Path, since otherwise it things the passed in path is a filename. While here, reduce the repetition of 8192. Sponsored by: Netflix Modified: head/usr.sbin/efidp/efidp.c Modified: head/usr.sbin/efidp/efidp.c ============================================================================== --- head/usr.sbin/efidp/efidp.c Tue Nov 21 07:35:24 2017 (r326050) +++ head/usr.sbin/efidp/efidp.c Tue Nov 21 07:35:29 2017 (r326051) @@ -27,6 +27,7 @@ #include __FBSDID("$FreeBSD$"); +#include #include #include #include @@ -133,16 +134,22 @@ main(int argc, char **argv) } else if (flag_parse) { efidp dp; ssize_t dplen; - char *str; + char *str, *walker; - dp = malloc(8192); + dplen = 8192; + dp = malloc(dplen); str = realloc(data, len + 1); if (str == NULL || dp == NULL) errx(1, "Can't allocate memory."); str[len] = '\0'; - dplen = efidp_parse_device_path(str, dp, 8192); + walker = str; + while (isspace(*walker)) + walker++; + dplen = efidp_parse_device_path(walker, dp, dplen); if (dplen == -1) - errx(1, "Can't parse %s", str); + errx(1, "Can't parse %s", walker); write(STDOUT_FILENO, dp, dplen); + free(dp); + free(str); } }