summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortedu <tedu@openbsd.org>2015-01-16 06:16:12 +0000
committertedu <tedu@openbsd.org>2015-01-16 06:16:12 +0000
commit3111eefda9c172ddb902efb107fd6a2098670dc5 (patch)
tree46ab23dcd17a2c302e4bb84fe7ae0c6e323e1a1d
parentjust to be careful, add a cpp guard that the sscanf sizes are ok (diff)
downloadwireguard-openbsd-3111eefda9c172ddb902efb107fd6a2098670dc5.tar.xz
wireguard-openbsd-3111eefda9c172ddb902efb107fd6a2098670dc5.zip
improve checksum parsing slightly. now handles filenames with spaces.
(though not names with ')'; sorry.)
-rw-r--r--usr.bin/signify/signify.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/usr.bin/signify/signify.c b/usr.bin/signify/signify.c
index ec7a791cd32..06d28dae022 100644
--- a/usr.bin/signify/signify.c
+++ b/usr.bin/signify/signify.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: signify.c,v 1.99 2015/01/16 06:00:39 tedu Exp $ */
+/* $OpenBSD: signify.c,v 1.100 2015/01/16 06:16:12 tedu Exp $ */
/*
* Copyright (c) 2013 Ted Unangst <tedu@openbsd.org>
*
@@ -595,11 +595,10 @@ verifychecksums(char *msg, int argc, char **argv, int quiet)
#if PATH_MAX < 1024 || HASHBUFSIZE < 224
#error sizes are wrong
#endif
- rv = sscanf(line, "%31s (%1023s = %223s",
+ rv = sscanf(line, "%31s (%1023[^)]) = %223s",
c.algo, c.file, c.hash);
- if (rv != 3 || c.file[0] == 0 || c.file[strlen(c.file)-1] != ')')
+ if (rv != 3)
errx(1, "unable to parse checksum line %s", line);
- c.file[strlen(c.file) - 1] = '\0';
line = endline;
if (argc) {
slot = ohash_qlookup(&myh, c.file);