Check the return value after an open syscall
authorLaszlo Papp <ext-laszlo.papp@nokia.com>
Wed, 9 Mar 2011 16:01:30 +0000 (18:01 +0200)
committerMiklos Szeredi <mszeredi@suse.cz>
Wed, 30 Mar 2011 17:34:58 +0000 (19:34 +0200)
lib/mount_util.c

index 5b660d653dd5fe2d5335c8283c0b35c7ea714384..aafddfbc18a3a077be29af31d405d84e59539ec5 100644 (file)
@@ -100,8 +100,10 @@ static int add_mount(const char *progname, const char *fsname,
                 * --no-canonicalize
                 */
                int fd = open("/dev/null", O_WRONLY);
-               dup2(fd, 1);
-               dup2(fd, 2);
+               if (fd >= 0) {
+                       dup2(fd, 1);
+                       dup2(fd, 2);
+               }
 
                sigprocmask(SIG_SETMASK, &oldmask, NULL);
                setuid(geteuid());