summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorMarc Espie <espie@cvs.openbsd.org>2019-12-22 06:37:26 +0000
committerMarc Espie <espie@cvs.openbsd.org>2019-12-22 06:37:26 +0000
commit9fb0c9b4e97aae9d85545977b2231e653b15ffc6 (patch)
tree3cabda83efb2877cd525cba8c3a42f2b342ac5fd /usr.bin
parent6b871978afb47af289a1f9c41ca45035ea493e65 (diff)
have parseb64file be non-destructive, so we can write the
comment in zsig without needing an extra copy okay tedu@
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/signify/signify.c4
-rw-r--r--usr.bin/signify/zsig.c12
2 files changed, 7 insertions, 9 deletions
diff --git a/usr.bin/signify/signify.c b/usr.bin/signify/signify.c
index 42cb6ae13d1..6a9660fb24f 100644
--- a/usr.bin/signify/signify.c
+++ b/usr.bin/signify/signify.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: signify.c,v 1.133 2019/09/09 13:50:06 deraadt Exp $ */
+/* $OpenBSD: signify.c,v 1.134 2019/12/22 06:37:25 espie Exp $ */
/*
* Copyright (c) 2013 Ted Unangst <tedu@openbsd.org>
*
@@ -145,6 +145,8 @@ parseb64file(const char *filename, char *b64, void *buf, size_t buflen,
errx(1, "unable to parse %s", filename);
if (memcmp(buf, PKALG, 2) != 0)
errx(1, "unsupported file %s", filename);
+ *commentend = '\n';
+ *b64end = '\n';
return b64end - b64 + 1;
}
diff --git a/usr.bin/signify/zsig.c b/usr.bin/signify/zsig.c
index eb27879e8b5..e3533fdd1d7 100644
--- a/usr.bin/signify/zsig.c
+++ b/usr.bin/signify/zsig.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: zsig.c,v 1.17 2019/12/09 09:41:54 espie Exp $ */
+/* $OpenBSD: zsig.c,v 1.18 2019/12/22 06:37:25 espie Exp $ */
/*
* Copyright (c) 2016 Marc Espie <espie@openbsd.org>
*
@@ -181,7 +181,7 @@ zverify(const char *pubkeyfile, const char *msgfile, const char *sigfile,
{
struct gzheader h;
size_t bufsize, len;
- char *p, *meta;
+ char *p;
uint8_t *bufend;
int fdin, fdout;
@@ -199,9 +199,6 @@ zverify(const char *pubkeyfile, const char *msgfile, const char *sigfile,
fake[8] = h.xflg;
len = h.endcomment-h.comment;
- meta = xmalloc(len+1);
- memcpy(meta, h.comment, len);
- meta[len] = 0;
p = verifyzdata(h.comment, len, sigfile,
pubkeyfile, keytype);
@@ -219,12 +216,11 @@ zverify(const char *pubkeyfile, const char *msgfile, const char *sigfile,
if (*p != '\n')
errx(1, "invalid signature");
- *(p++) = 0;
fdout = xopen(msgfile, O_CREAT|O_TRUNC|O_NOFOLLOW|O_WRONLY, 0666);
writeall(fdout, fake, sizeof fake, msgfile);
- writeall(fdout, meta, len+1, msgfile);
- free(meta);
+ writeall(fdout, h.comment, len+1, msgfile);
+ *(p++) = 0;
copy_blocks(fdout, fdin, p, h.endcomment, bufsize, bufend);
free(h.buffer);
close(fdout);