aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@openbsd.org>2015-07-16 22:11:01 +0000
committerNicholas Marriott <nicm@openbsd.org>2015-07-16 22:11:01 +0000
commitd22ea3dc8bd52907291af8b41b33260ca74a1e69 (patch)
tree7a3d274612e3044eeaa74a3dbfdd91f824d9a44c
parentf91b339a85cb2fb0b2c716bcd28eea1f73854190 (diff)
downloadopendoas-d22ea3dc8bd52907291af8b41b33260ca74a1e69.tar.gz
Missing reallocarray check in doas.c (ok tedu) and a calloc in parse.y
as well.
-rw-r--r--doas.c4
-rw-r--r--parse.y4
2 files changed, 6 insertions, 2 deletions
diff --git a/doas.c b/doas.c
index 5ceb42e..ec727df 100644
--- a/doas.c
+++ b/doas.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: doas.c,v 1.3 2015/07/16 21:55:03 tedu Exp $ */
+/* $OpenBSD: doas.c,v 1.4 2015/07/16 21:57:54 deraadt 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/parse.y b/parse.y
index 4729b4e..1b3a542 100644
--- a/parse.y
+++ b/parse.y
@@ -1,4 +1,4 @@
-/* $OpenBSD$ */
+/* $OpenBSD: parse.y,v 1.1 2015/07/16 20:44:21 tedu 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;