Skip to content

Commit

Permalink
conf: always close pipe in run_userns_fn()
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
  • Loading branch information
Christian Brauner committed Jul 29, 2018
1 parent 979f9e3 commit adaffdd
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/lxc/conf.c
Expand Up @@ -4121,6 +4121,7 @@ struct userns_fn_data {

static int run_userns_fn(void *data)
{
int ret;
char c;
struct userns_fn_data *d = data;

Expand All @@ -4130,14 +4131,14 @@ static int run_userns_fn(void *data)
/* Wait for parent to finish establishing a new mapping in the user
* namespace we are executing in.
*/
if (lxc_read_nointr(d->p[0], &c, 1) != 1)
return -1;

ret = lxc_read_nointr(d->p[0], &c, 1);
/* Close read end of the pipe. */
close(d->p[0]);
if (ret != 1)
return -1;

if (d->fn_name)
TRACE("calling function \"%s\"", d->fn_name);
TRACE("Calling function \"%s\"", d->fn_name);

/* Call function to run. */
return d->fn(d->arg);
Expand Down

0 comments on commit adaffdd

Please sign in to comment.