]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
tests: Avoid possible error in testExecRestart
authorJohn Ferlan <jferlan@redhat.com>
Tue, 23 Jul 2019 12:14:50 +0000 (08:14 -0400)
committerJohn Ferlan <jferlan@redhat.com>
Tue, 23 Jul 2019 17:40:54 +0000 (13:40 -0400)
If the dup2 fails, then we aren't going to get the correct result.

Found by Coverity

Signed-off-by: John Ferlan <jferlan@redhat.com>
ACKed-by: Peter Krempa <pkrempa@redhat.com>
tests/virnetdaemontest.c

index eae630a8f1368e9df361d0956dd89668208f9ad5..816bfe05d409cc531f7851d6232cdaece5dfc924 100644 (file)
@@ -287,10 +287,13 @@ static int testExecRestart(const void *opaque)
      * fds 100->103 for something else, which is probably
      * fairly reasonable in general
      */
-    dup2(fdserver[0], 100);
-    dup2(fdserver[1], 101);
-    dup2(fdclient[0], 102);
-    dup2(fdclient[1], 103);
+    if (dup2(fdserver[0], 100) < 0 ||
+        dup2(fdserver[1], 101) < 0 ||
+        dup2(fdclient[0], 102) < 0 ||
+        dup2(fdclient[1], 103) < 0) {
+        virReportSystemError(errno, "%s", "dup2() failed");
+        goto cleanup;
+    }
 
     if (virAsprintf(&infile, "%s/virnetdaemondata/input-data-%s.json",
                     abs_srcdir, data->jsonfile) < 0)