diff options
author | 2014-01-03 17:13:42 +0000 | |
---|---|---|
committer | 2014-01-03 17:13:42 +0000 | |
commit | f030c3d3bdd64c9e75ebdf526c4b8f07d6cd00c3 (patch) | |
tree | f27f85f61735693d4a6530ee0fbf0f49a8e8acc7 | |
parent | synch with signify usage (diff) | |
download | wireguard-openbsd-f030c3d3bdd64c9e75ebdf526c4b8f07d6cd00c3.tar.xz wireguard-openbsd-f030c3d3bdd64c9e75ebdf526c4b8f07d6cd00c3.zip |
replace hand rolled strchr with strchr
-rw-r--r-- | usr.bin/signify/signify.c | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/usr.bin/signify/signify.c b/usr.bin/signify/signify.c index ff5caea9be0..ff299b241a1 100644 --- a/usr.bin/signify/signify.c +++ b/usr.bin/signify/signify.c @@ -1,4 +1,4 @@ -/* $OpenBSD: signify.c,v 1.9 2014/01/03 17:10:27 espie Exp $ */ +/* $OpenBSD: signify.c,v 1.10 2014/01/03 17:13:42 tedu Exp $ */ /* * Copyright (c) 2013 Ted Unangst <tedu@openbsd.org> * @@ -109,19 +109,18 @@ static void readb64file(const char *filename, void *buf, size_t len) { char b64[2048]; - int i, rv, fd; + int rv, fd; + char *commentend; fd = xopen(filename, O_RDONLY | O_NOFOLLOW, 0); memset(b64, 0, sizeof(b64)); rv = read(fd, b64, sizeof(b64) - 1); if (rv == -1) err(1, "read from %s", filename); - for (i = 0; i < rv; i++) - if (b64[i] == '\n') - break; - if (i == rv) + commentend = strchr(b64, '\n'); + if (!commentend) errx(1, "no newline in %s", filename); - rv = b64_pton(b64 + i, buf, len); + rv = b64_pton(commentend + 1, buf, len); if (rv != len) errx(1, "invalid b64 encoding in %s", filename); memset(b64, 0, sizeof(b64)); |