opendoas

A portable version of the OpenBSD `doas` command
git clone https://pi.duncano.de/git/opendoas.git
Log | Files | Refs | README | LICENSE

commit d22ea3dc8bd52907291af8b41b33260ca74a1e69
parent f91b339a85cb2fb0b2c716bcd28eea1f73854190
Author: Nicholas Marriott <nicm@openbsd.org>
Date:   Thu, 16 Jul 2015 22:11:01 +0000

Missing reallocarray check in doas.c (ok tedu) and a calloc in parse.y
as well.

Diffstat:
doas.c | 4+++-
parse.y | 4+++-
2 files changed, 6 insertions(+), 2 deletions(-)

diff --git 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 @@ -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;