Whamcloud - gitweb
libss: Add missing error handling for fdopen()
authorLukas Czerner <lczerner@redhat.com>
Fri, 6 Aug 2021 09:58:19 +0000 (11:58 +0200)
committerTheodore Ts'o <tytso@mit.edu>
Tue, 10 Aug 2021 15:02:57 +0000 (11:02 -0400)
Signed-off-by: Lukas Czerner <lczerner@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
lib/ss/list_rqs.c

index 021a383..89e37bb 100644 (file)
@@ -12,6 +12,9 @@
  */
 #include "config.h"
 #include "ss_internal.h"
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
 #include <signal.h>
 #include <setjmp.h>
 #include <sys/wait.h>
@@ -46,6 +49,12 @@ void ss_list_requests(int argc __SS_ATTR((unused)),
         return;
     }
     output = fdopen(fd, "w");
+    if (!output) {
+        perror("fdopen");
+        close(fd);
+        (void) signal(SIGINT, func);
+        return;
+    }
     sigprocmask(SIG_SETMASK, &omask, (sigset_t *) 0);
 
     fprintf (output, "Available %s requests:\n\n",