diff options
author | tobhe <tobhe@cvs.openbsd.org> | 2020-11-11 18:24:56 +0000 |
---|---|---|
committer | tobhe <tobhe@cvs.openbsd.org> | 2020-11-11 18:24:56 +0000 |
commit | 18cc1afb7d4775743ebbdcf27a5d4a50f5eb01b6 (patch) | |
tree | dbb77dd2cee60e9eb7b6435e1f50064e4389f7ac /sbin | |
parent | 10bbab4416166f8d1876b1f070e8cb1f59ffe46f (diff) |
Cleanup after proc_init() in proc_close().
Diffstat (limited to 'sbin')
-rw-r--r-- | sbin/iked/proc.c | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/sbin/iked/proc.c b/sbin/iked/proc.c index 55d556db9ea..68a36522776 100644 --- a/sbin/iked/proc.c +++ b/sbin/iked/proc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: proc.c,v 1.32 2020/04/08 20:04:19 tobhe Exp $ */ +/* $OpenBSD: proc.c,v 1.33 2020/11/11 18:24:55 tobhe Exp $ */ /* * Copyright (c) 2010 - 2014 Reyk Floeter <reyk@openbsd.org> @@ -260,7 +260,7 @@ proc_listen(struct privsep *ps, struct privsep_proc *procs, size_t nproc) void proc_close(struct privsep *ps) { - unsigned int dst, n; + unsigned int src, dst, n, i, j; struct privsep_pipes *pp; if (ps == NULL) @@ -284,6 +284,20 @@ proc_close(struct privsep *ps) } free(ps->ps_ievs[dst]); } + + /* undo proc_init() */ + for (src = 0; src < PROC_MAX; src++) { + for (i = 0; i < ps->ps_ninstances; i++) { + pp = &ps->ps_pipes[src][i]; + for (dst = 0; dst < PROC_MAX; dst++) { + for (j = 0; j < ps->ps_ninstances; j++) + if (pp->pp_pipes[dst][j] != -1) + close(pp->pp_pipes[dst][j]); + free(pp->pp_pipes[dst]); + } + } + free(ps->ps_pipes[src]); + } } void |