]> Git Repo - qemu.git/commitdiff
slirp: fork_exec(): Don't close() a negative number in fork_exec()
authorPeter Maydell <[email protected]>
Sun, 9 Jul 2017 17:54:22 +0000 (18:54 +0100)
committerSamuel Thibault <[email protected]>
Sat, 15 Jul 2017 12:28:25 +0000 (14:28 +0200)
In a fork_exec() error path we try to closesocket(s) when s might
be a negative number because the thing that failed was the
qemu_socket() call. Add a guard so we don't do this.

(Spotted by Coverity: CID 1005727 issue 1 of 2.)

Signed-off-by: Peter Maydell <[email protected]>
Reviewed-by: Dr. David Alan Gilbert <[email protected]>
Signed-off-by: Samuel Thibault <[email protected]>
slirp/misc.c

index 88e9d94197a6ae28fabc78918c72b65200858c54..260187b6b6288346a4f96865dfa4ee20db488128 100644 (file)
@@ -112,7 +112,9 @@ fork_exec(struct socket *so, const char *ex, int do_pty)
                    bind(s, (struct sockaddr *)&addr, addrlen) < 0 ||
                    listen(s, 1) < 0) {
                        error_report("Error: inet socket: %s", strerror(errno));
-                       closesocket(s);
+                       if (s >= 0) {
+                           closesocket(s);
+                       }
 
                        return 0;
                }
This page took 0.026661 seconds and 4 git commands to generate.