Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 21 Nov 2017 07:35:30 +0000 (UTC)
From:      Warner Losh <imp@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r326051 - head/usr.sbin/efidp
Message-ID:  <201711210735.vAL7ZULl030024@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
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 <sys/cdefs.h>
 __FBSDID("$FreeBSD$");
 
+#include <ctype.h>
 #include <efivar.h>
 #include <efivar-dp.h>
 #include <err.h>
@@ -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);
 	}
 }



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