]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
switch_root: check open() return value [coverity scan]
authorKarel Zak <kzak@redhat.com>
Fri, 7 Sep 2012 11:02:42 +0000 (13:02 +0200)
committerKarel Zak <kzak@redhat.com>
Fri, 7 Sep 2012 11:02:42 +0000 (13:02 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
sys-utils/switch_root.c

index bcd801d5fbb6c1ed368a1d2cfed6a746ad9a5efe..f0ef67745fcade5ae1cf9251b6a745f425ea53f5 100644 (file)
@@ -154,6 +154,10 @@ static int switchroot(const char *newroot)
        }
 
        cfd = open("/", O_RDONLY);
+       if (cfd < 0) {
+               warn(_("cannot open %s"), "/");
+               return -1;
+       }
 
        if (mount(newroot, "/", NULL, MS_MOVE, NULL) < 0) {
                close(cfd);