aboutsummaryrefslogtreecommitdiff
path: root/usr.sbin/efidp/efidp.c
diff options
context:
space:
mode:
authorWarner Losh <imp@FreeBSD.org>2017-11-21 07:35:29 +0000
committerWarner Losh <imp@FreeBSD.org>2017-11-21 07:35:29 +0000
commitc0a0f12f9b7c596f08ab58fe4d42b7c75741da3e (patch)
treee46b449dd1299368235d97140b38ce0d318131f6 /usr.sbin/efidp/efidp.c
parent1c3a0e1a46ac16503a2d250b38d4b0f05e7e9cab (diff)
downloadsrc-c0a0f12f9b7c596f08ab58fe4d42b7c75741da3e.tar.gz
src-c0a0f12f9b7c596f08ab58fe4d42b7c75741da3e.zip
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
Notes
Notes: svn path=/head/; revision=326051
Diffstat (limited to 'usr.sbin/efidp/efidp.c')
-rw-r--r--usr.sbin/efidp/efidp.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/usr.sbin/efidp/efidp.c b/usr.sbin/efidp/efidp.c
index a96cf9f70b6d..c9b100bd6308 100644
--- a/usr.sbin/efidp/efidp.c
+++ b/usr.sbin/efidp/efidp.c
@@ -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);
}
}