From 34067b5c362d5070e91364cc1ed6487497462b42 Mon Sep 17 00:00:00 2001 From: Richard Jones Date: Thu, 6 May 2010 20:32:09 +0100 Subject: [PATCH] daemon: Change command to abort() on resource problems. The comment in the code describes it thus: /* Note: abort is used in a few places along the error paths early * in this function. This is because (a) cleaning up correctly is * very complex at these places and (b) abort is used when a * resource problem is indicated which would be due to much more * serious issues - eg. memory or file descriptor leaks. We * wouldn't expect fork(2) or pipe(2) to fail in normal * circumstances. */ --- daemon/guestfsd.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/daemon/guestfsd.c b/daemon/guestfsd.c index 03a975a..be79300 100644 --- a/daemon/guestfsd.c +++ b/daemon/guestfsd.c @@ -1,5 +1,5 @@ /* libguestfs - the guestfsd daemon - * Copyright (C) 2009 Red Hat Inc. + * Copyright (C) 2009-2010 Red Hat Inc. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -738,19 +738,24 @@ commandrvf (char **stdoutput, char **stderror, int flags, printf ("\n"); } + /* Note: abort is used in a few places along the error paths early + * in this function. This is because (a) cleaning up correctly is + * very complex at these places and (b) abort is used when a + * resource problems is indicated which would be due to much more + * serious issues - eg. memory or file descriptor leaks. We + * wouldn't expect fork(2) or pipe(2) to fail in normal + * circumstances. + */ + if (pipe (so_fd) == -1 || pipe (se_fd) == -1) { perror ("pipe"); - return -1; + abort (); } pid = fork (); if (pid == -1) { perror ("fork"); - close (so_fd[0]); - close (so_fd[1]); - close (se_fd[0]); - close (se_fd[1]); - return -1; + abort (); } if (pid == 0) { /* Child process. */ -- 1.8.3.1