]> git.armaanb.net Git - opendoas.git/commitdiff
Missing reallocarray check in doas.c (ok tedu) and a calloc in parse.y
authorNicholas Marriott <nicm@openbsd.org>
Thu, 16 Jul 2015 22:11:01 +0000 (22:11 +0000)
committerNicholas Marriott <nicm@openbsd.org>
Thu, 16 Jul 2015 22:11:01 +0000 (22:11 +0000)
as well.

doas.c
parse.y

diff --git a/doas.c b/doas.c
index 5ceb42e51530685db146980355f6afc2f4056f94..ec727df3931c02d2dac84efa3cf0c5aa6111c31e 100644 (file)
--- 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 4729b4ee19b3ee399330e1aa62292bc2414d5e97..1b3a54261e908e95f11f3707fe4420bff70c20ef 100644 (file)
--- 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;