diff options
author | Sebastien Marie <semarie@cvs.openbsd.org> | 2016-03-15 15:05:24 +0000 |
---|---|---|
committer | Sebastien Marie <semarie@cvs.openbsd.org> | 2016-03-15 15:05:24 +0000 |
commit | cc74730c882c87194c20bb6d5a0e9ba65accb6ed (patch) | |
tree | 9e2feb1fc0392f4b8c33aa53a29c377e0ffe2442 /sys | |
parent | dbfdd20ef9ded7255ce71827e2566bd87166dcf5 (diff) |
pledge: wl_paths: corrects a memory leak in error code path and an evaluation
order ("a += b > c" is the same as "a += (b > c)" which is wrong here)
ok jca@
Diffstat (limited to 'sys')
-rw-r--r-- | sys/kern/kern_pledge.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/sys/kern/kern_pledge.c b/sys/kern/kern_pledge.c index 113a8013b67..1906c9f77b6 100644 --- a/sys/kern/kern_pledge.c +++ b/sys/kern/kern_pledge.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_pledge.c,v 1.155 2016/03/13 18:40:52 semarie Exp $ */ +/* $OpenBSD: kern_pledge.c,v 1.156 2016/03/15 15:05:23 semarie Exp $ */ /* * Copyright (c) 2015 Nicholas Marriott <nicm@openbsd.org> @@ -503,8 +503,10 @@ sys_pledge(struct proc *p, void *v, register_t *retval) /* resolved is allocated only if !error */ break; - if (maxargs += resolvedlen > ARG_MAX) { + maxargs += resolvedlen; + if (maxargs > ARG_MAX) { error = E2BIG; + free(resolved, M_TEMP, resolvedlen); break; } wl->wl_paths[i].name = resolved; |