diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/usr.bin/apply/apply.c | 113 | ||||
-rw-r--r-- | src/usr.bin/calendar/calendars/calendar.openbsd | 6 | ||||
-rw-r--r-- | src/usr.bin/jot/jot.c | 149 | ||||
-rw-r--r-- | src/usr.bin/signify/crypto_api.h | 5 | ||||
-rw-r--r-- | src/usr.bin/signify/signify.1 | 8 |
5 files changed, 134 insertions, 147 deletions
diff --git a/src/usr.bin/apply/apply.c b/src/usr.bin/apply/apply.c index ee9e481..daa3d1d 100644 --- a/src/usr.bin/apply/apply.c +++ b/src/usr.bin/apply/apply.c @@ -1,4 +1,4 @@ -/* $OpenBSD: apply.c,v 1.27 2015/10/10 17:48:34 deraadt Exp $ */ +/* $OpenBSD: apply.c,v 1.29 2018/04/01 17:45:05 bluhm Exp $ */ /* $NetBSD: apply.c,v 1.3 1995/03/25 03:38:23 glass Exp $ */ /*- @@ -44,15 +44,47 @@ #include <string.h> #include <unistd.h> +#define ISMAGICNO(p) \ + (p)[0] == magic && isdigit((unsigned char)(p)[1]) && (p)[1] != '0' + __dead void usage(void); static int mysystem(const char *); +char *str; +size_t sz; + +void +stradd(char *p) +{ + size_t n; + + n = strlen(p); + if (str == NULL) { + sz = (n / 1024 + 1) * 1024; + if ((str = malloc(sz)) == NULL) + err(1, "malloc"); + *str = '\0'; + } else if (sz - strlen(str) <= n) { + sz += (n / 1024 + 1) * 1024; + if ((str = realloc(str, sz)) == NULL) + err(1, "realloc"); + } + strlcat(str, p, sz); +} + +void +strset(char *p) +{ + if (str != NULL) + str[0] = '\0'; + stradd(p); +} + int main(int argc, char *argv[]) { - int ch, clen, debug, i, l, magic, n, nargs, rval; - char *c, *c2, *cmd, *p, *q; - size_t len; + int ch, debug, i, magic, n, nargs, rval; + char buf[4], *cmd, *p; if (pledge("stdio proc exec", NULL) == -1) err(1, "pledge"); @@ -63,7 +95,7 @@ main(int argc, char *argv[]) while ((ch = getopt(argc, argv, "a:d0123456789")) != -1) switch (ch) { case 'a': - if (optarg[1] != '\0') + if (optarg[0] == '\0' || optarg[1] != '\0') errx(1, "illegal magic character specification."); magic = optarg[0]; @@ -93,8 +125,7 @@ main(int argc, char *argv[]) * largest one. */ for (n = 0, p = argv[0]; *p != '\0'; ++p) - if (p[0] == magic && - isdigit((unsigned char)p[1]) && p[1] != '0') { + if (ISMAGICNO(p)) { ++p; if (p[0] - '0' > n) n = p[0] - '0'; @@ -106,28 +137,15 @@ main(int argc, char *argv[]) * the end to consume (nargs) arguments each time round the loop. * Allocate enough space to hold the maximum command. */ + strset(argv[0]); if (n == 0) { - len = sizeof("exec ") - 1 + - strlen(argv[0]) + 9 * (sizeof(" %1") - 1) + 1; - if ((cmd = malloc(len)) == NULL) - err(1, NULL); - /* If nargs not set, default to a single argument. */ if (nargs == -1) nargs = 1; - l = snprintf(cmd, len, "exec %s", argv[0]); - if (l >= len || l == -1) - errx(1, "error building exec string"); - len -= l; - p = cmd + l; - for (i = 1; i <= nargs; i++) { - l = snprintf(p, len, " %c%d", magic, i); - if (l >= len || l == -1) - errx(1, "error numbering arguments"); - len -= l; - p += l; + snprintf(buf, sizeof(buf), " %c%d", magic, i); + stradd(buf); } /* @@ -136,19 +154,10 @@ main(int argc, char *argv[]) */ if (nargs == 0) nargs = 1; - } else { - if (asprintf(&cmd, "exec %s", argv[0]) == -1) - err(1, NULL); + } else nargs = n; - } - - /* - * Grab some space in which to build the command. Allocate - * as necessary later, but no reason to build it up slowly - * for the normal case. - */ - if ((c = malloc(clen = 1024)) == NULL) - err(1, NULL); + if ((cmd = strdup(str)) == NULL) + err(1, "strdup"); /* * (argc) and (argv) are still offset by one to make it simpler to @@ -156,35 +165,21 @@ main(int argc, char *argv[]) * equals 1 means that all the (argv) has been consumed. */ for (rval = 0; argc > nargs; argc -= nargs, argv += nargs) { - /* - * Find a max value for the command length, and ensure - * there's enough space to build it. - */ - for (l = strlen(cmd), i = 0; i < nargs; i++) - l += strlen(argv[i+1]); - if (l > clen) { - if ((c2 = realloc(c, l)) == NULL) - err(1, NULL); - c = c2; - clen = l; - } + strset("exec "); /* Expand command argv references. */ - for (p = cmd, q = c; *p != '\0'; ++p) - if (p[0] == magic && - isdigit((unsigned char)p[1]) && p[1] != '0') { - strlcpy(q, argv[(++p)[0] - '0'], c + clen - q); - q += strlen(q); - } else - *q++ = *p; - - /* Terminate the command string. */ - *q = '\0'; + for (p = cmd; *p != '\0'; ++p) + if (ISMAGICNO(p)) + stradd(argv[*(++p) - '0']); + else { + strlcpy(buf, p, 2); + stradd(buf); + } /* Run the command. */ if (debug) - (void)printf("%s\n", c); - else if (mysystem(c)) + (void)printf("%s\n", str); + else if (mysystem(str)) rval = 1; } diff --git a/src/usr.bin/calendar/calendars/calendar.openbsd b/src/usr.bin/calendar/calendars/calendar.openbsd index 208b23b..22f4009 100644 --- a/src/usr.bin/calendar/calendars/calendar.openbsd +++ b/src/usr.bin/calendar/calendars/calendar.openbsd @@ -1,7 +1,7 @@ /* * OpenBSD-related dates to celebrate * - * $OpenBSD: calendar.openbsd,v 1.38 2016/09/03 13:37:45 guenther Exp $ + * $OpenBSD: calendar.openbsd,v 1.39 2018/03/01 20:48:11 jmc Exp $ */ #ifndef _calendar_openbsd_ @@ -53,7 +53,7 @@ May 29 t2k13: General hackathon, Toronto, Canada, 43 developers, 2013 May 30 c2k9: General hackathon, Edmonton, Alberta, 46 developers, 2009 May 31 Initial cut at OpenNTP, 2004 Jun 01 OpenBSD 2.1 released, first time on CD (double set), 1997 -Jun 04 c99: First hackathon (IPSec), Calgary, Alberta, 10 developers, 1999 +Jun 04 c99: First hackathon (IPsec), Calgary, Alberta, 10 developers, 1999 Jun 04 c2k2: General hackathon, Calgary, Alberta, 42 developers, 2002 Jun 06 c2k8: General hackathon, Edmonton, Alberta, 55 developers, 2008 Jun 14 r2k6: First network hackathon, Hamburg, Germany, 6 developers, 2006 @@ -79,7 +79,7 @@ Aug 12 OpenBSD/sparc is switched to wscons, 2002 Aug 16 IPX network stack added to OpenBSD, from FreeBSD, 1996 Aug 17 c2k1-2: Sparc64 hackathon, Washington D.C., 12 developers, 2001 Aug 17 OpenBSD/sparc64 port is added, from NetBSD, 2001 -Aug 28 k2k6: IPSec hackathon, Schloss Kransberg, Germany, 14 developers, 2006 +Aug 28 k2k6: IPsec hackathon, Schloss Kransberg, Germany, 14 developers, 2006 Sep 01 Support for the sparc (32bit) architecture removed, 2016 Sep 03 Support for the zaurus architecture removed, 2016 Sep 16 s2k11: General hackathon, Ljubljana, Slovenia, 25 developers, 2011 diff --git a/src/usr.bin/jot/jot.c b/src/usr.bin/jot/jot.c index 0de3a51..499840d 100644 --- a/src/usr.bin/jot/jot.c +++ b/src/usr.bin/jot/jot.c @@ -1,4 +1,4 @@ -/* $OpenBSD: jot.c,v 1.36 2016/09/02 14:23:09 tb Exp $ */ +/* $OpenBSD: jot.c,v 1.45 2018/01/13 15:43:39 tb Exp $ */ /* $NetBSD: jot.c,v 1.3 1994/12/02 20:29:43 pk Exp $ */ /*- @@ -59,8 +59,8 @@ static double begin = 1; static double ender = 100; static double step = 1; -static char format[BUFSIZ]; -static char sepstring[BUFSIZ] = "\n"; +static char *format = ""; +static char *sepstring = "\n"; static int prec = -1; static bool boring; static bool chardata; @@ -85,7 +85,7 @@ main(int argc, char *argv[]) unsigned int mask = 0; int n = 0; int ch; - const char *errstr; + const char *errstr; if (pledge("stdio", NULL) == -1) err(1, "pledge"); @@ -94,9 +94,7 @@ main(int argc, char *argv[]) switch (ch) { case 'b': boring = true; - if (strlcpy(format, optarg, sizeof(format)) >= - sizeof(format)) - errx(1, "-b word too long"); + format = optarg; break; case 'c': chardata = true; @@ -114,14 +112,10 @@ main(int argc, char *argv[]) randomize = true; break; case 's': - if (strlcpy(sepstring, optarg, sizeof(sepstring)) >= - sizeof(sepstring)) - errx(1, "-s string too long"); + sepstring = optarg; break; case 'w': - if (strlcpy(format, optarg, sizeof(format)) >= - sizeof(format)) - errx(1, "-w word too long"); + format = optarg; break; default: usage(); @@ -176,7 +170,8 @@ main(int argc, char *argv[]) argv[4]); } - getformat(); + if (!boring) + getformat(); if (!randomize) { /* @@ -355,41 +350,32 @@ getprec(char *s) static void getformat(void) { - char *p, *p2; - int dot, hash, space, sign, numbers = 0; - size_t sz; + char *p; - if (boring) /* no need to bother */ - return; - for (p = format; *p != '\0'; p++) /* look for '%' */ - if (*p == '%') { - if (*(p+1) != '%') - break; - p++; /* leave %% alone */ - } - sz = sizeof(format) - strlen(format) - 1; - if (*p == '\0' && !chardata) { - int n; + p = format; + while ((p = strchr(p, '%')) != NULL && p[1] == '%') + p += 2; - n = snprintf(p, sz, "%%.%df", prec); - if (n == -1 || n >= (int)sz) - errx(1, "-w word too long"); - } else if (*p == '\0' && chardata) { - if (strlcpy(p, "%c", sz) >= sz) - errx(1, "-w word too long"); - intdata = true; - } else if (*(p+1) == '\0') { - if (sz <= 0) - errx(1, "-w word too long"); + if (p == NULL && !chardata) { + if (asprintf(&format, "%s%%.%df", format, prec) < 0) + err(1, NULL); + } else if (p == NULL && chardata) { + if (asprintf(&format, "%s%%c", format) < 0) + err(1, NULL); + } else if (p[1] == '\0') { /* cannot end in single '%' */ - strlcat(format, "%", sizeof format); + if (asprintf(&format, "%s%%", format) < 0) + err(1, NULL); } else { /* * Allow conversion format specifiers of the form * %[#][ ][{+,-}][0-9]*[.[0-9]*]? where ? must be one of - * [l]{d,i,o,u,x} or {f,e,g,E,G,d,o,x,D,O,U,X,c,u} + * [l]{d,i,o,u,x} or {f,e,g,F,E,G,d,o,x,D,O,U,X,c,u} */ - p2 = p++; + char *fmt; + int dot, hash, space, sign, numbers; + + fmt = p++; dot = hash = space = sign = numbers = 0; while (!isalpha((unsigned char)*p)) { if (isdigit((unsigned char)*p)) { @@ -407,53 +393,62 @@ getformat(void) if (*p == 'l') { longdata = true; if (*++p == 'l') { - if (p[1] != '\0') - p++; + p++; goto fmt_broken; } } switch (*p) { - case 'o': case 'u': case 'x': case 'X': - intdata = nosign = true; - break; - case 'd': case 'i': + case 'd': + case 'i': intdata = true; break; + case 'o': + case 'u': + case 'x': + case 'X': + intdata = nosign = true; + break; case 'D': - if (!longdata) { - intdata = true; - break; - } - case 'O': case 'U': - if (!longdata) { - intdata = nosign = true; - break; - } + if (longdata) + goto fmt_broken; + longdata = intdata = true; /* same as %ld */ + break; + case 'O': + case 'U': + if (longdata) + goto fmt_broken; + longdata = intdata = nosign = true; /* same as %l[ou] */ + break; case 'c': - if (!(intdata | longdata)) { - chardata = true; - break; - } - case 'h': case 'n': case 'p': case 'q': case 's': case 'L': - case '$': case '*': - goto fmt_broken; - case 'f': case 'e': case 'g': case 'E': case 'G': - if (!longdata) - break; - /* FALLTHROUGH */ + if (longdata) + goto fmt_broken; + chardata = true; + break; + case 'e': + case 'E': + case 'f': + case 'F': + case 'g': + case 'G': + if (longdata) + goto fmt_broken; + /* No cast needed for printing in putdata() */ + break; default: fmt_broken: - *++p = '\0'; - errx(1, "illegal or unsupported format '%s'", p2); + errx(1, "illegal or unsupported format '%.*s'", + (int)(p + 1 - fmt), fmt); } - while (*++p != '\0') - if (*p == '%' && *(p+1) != '\0' && *(p+1) != '%') + + while ((p = strchr(p, '%')) != NULL && p[1] == '%') + p += 2; + + if (p != NULL) { + if (p[1] != '\0') errx(1, "too many conversions"); - else if (*p == '%' && *(p+1) == '%') - p++; - else if (*p == '%' && *(p+1) == '\0') { - strlcat(format, "%", sizeof format); - break; - } + /* cannot end in single '%' */ + if (asprintf(&format, "%s%%", format) < 0) + err(1, NULL); + } } } diff --git a/src/usr.bin/signify/crypto_api.h b/src/usr.bin/signify/crypto_api.h index d7b0a2e..540a7c2 100644 --- a/src/usr.bin/signify/crypto_api.h +++ b/src/usr.bin/signify/crypto_api.h @@ -1,4 +1,4 @@ -/* $OpenBSD: crypto_api.h,v 1.1 2014/07/22 00:41:19 deraadt Exp $ */ +/* $OpenBSD: crypto_api.h,v 1.2 2018/01/16 21:42:40 naddy Exp $ */ /* * Assembled from generated headers and source files by Markus Friedl. @@ -16,9 +16,6 @@ typedef uint32_t crypto_uint32; #define randombytes(buf, buf_len) arc4random_buf((buf), (buf_len)) -#define crypto_hashblocks_sha512_STATEBYTES 64U -#define crypto_hashblocks_sha512_BLOCKBYTES 128U - int crypto_hashblocks_sha512(unsigned char *, const unsigned char *, unsigned long long); diff --git a/src/usr.bin/signify/signify.1 b/src/usr.bin/signify/signify.1 index d3cc781..1e2f61e 100644 --- a/src/usr.bin/signify/signify.1 +++ b/src/usr.bin/signify/signify.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: signify.1,v 1.42 2017/08/20 22:36:10 deraadt Exp $ +.\" $OpenBSD: signify.1,v 1.43 2018/02/28 14:56:46 deraadt Exp $ .\" .\"Copyright (c) 2013 Marc Espie <espie@openbsd.org> .\"Copyright (c) 2013 Ted Unangst <tedu@openbsd.org> @@ -14,7 +14,7 @@ .\"WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN .\"ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\"OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -.Dd $Mdocdate: August 20 2017 $ +.Dd $Mdocdate: February 28 2018 $ .Dt SIGNIFY 1 .Os .Sh NAME @@ -165,12 +165,12 @@ Verify a release directory containing .Pa SHA256.sig and a full set of release files: .Bd -literal -offset indent -compact -$ signify -C -p /etc/signify/openbsd-63-base.pub -x SHA256.sig +$ signify -C -p /etc/signify/openbsd-64-base.pub -x SHA256.sig .Ed .Pp Verify a bsd.rd before an upgrade: .Bd -literal -offset indent -compact -$ signify -C -p /etc/signify/openbsd-63-base.pub -x SHA256.sig bsd.rd +$ signify -C -p /etc/signify/openbsd-64-base.pub -x SHA256.sig bsd.rd .Ed .Pp Sign a gzip archive: |