summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornicm <nicm@openbsd.org>2015-07-16 22:11:01 +0000
committernicm <nicm@openbsd.org>2015-07-16 22:11:01 +0000
commit9b960859788c66a11004b8708cd2afc70905367e (patch)
tree29aa00d0a31555f18176f19a7f8fd59a55c710fc
parentRemove a piece of code that has been commented out for 16 years and was (diff)
downloadwireguard-openbsd-9b960859788c66a11004b8708cd2afc70905367e.tar.xz
wireguard-openbsd-9b960859788c66a11004b8708cd2afc70905367e.zip
Missing reallocarray check in doas.c (ok tedu) and a calloc in parse.y
as well.
-rw-r--r--usr.bin/doas/doas.c4
-rw-r--r--usr.bin/doas/parse.y4
2 files changed, 6 insertions, 2 deletions
diff --git a/usr.bin/doas/doas.c b/usr.bin/doas/doas.c
index 1479ff2f8a8..89f78261dba 100644
--- a/usr.bin/doas/doas.c
+++ b/usr.bin/doas/doas.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: doas.c,v 1.4 2015/07/16 21:57:54 deraadt Exp $ */
+/* $OpenBSD: doas.c,v 1.5 2015/07/16 22:11:01 nicm Exp $ */
/*
* Copyright (c) 2015 Ted Unangst <tedu@openbsd.org>
*
@@ -188,6 +188,8 @@ copyenv(const char **oldenvp, struct rule *rule)
if ((rule->options & KEEPENV) && !rule->envlist) {
j = arraylen(oldenvp);
envp = reallocarray(NULL, j + 1, sizeof(char *));
+ if (!envp)
+ err(1, "reallocarray");
for (i = 0; i < j; i++) {
if (!(envp[i] = strdup(oldenvp[i])))
err(1, "strdup");
diff --git a/usr.bin/doas/parse.y b/usr.bin/doas/parse.y
index 9361034bd2e..f55d58b60cf 100644
--- a/usr.bin/doas/parse.y
+++ b/usr.bin/doas/parse.y
@@ -1,4 +1,4 @@
-/* $OpenBSD: parse.y,v 1.1 2015/07/16 20:44:21 tedu Exp $ */
+/* $OpenBSD: parse.y,v 1.2 2015/07/16 22:11:01 nicm Exp $ */
/*
* Copyright (c) 2015 Ted Unangst <tedu@openbsd.org>
*
@@ -60,6 +60,8 @@ grammar: /* empty */
rule: action ident target cmd {
struct rule *r;
r = calloc(1, sizeof(*r));
+ if (!r)
+ errx(1, "can't allocate rule");
r->action = $1.action;
r->options = $1.options;
r->envlist = $1.envlist;