slirp: check system() success
we shouldn't call W*() macros until we check that fork worked.
Signed-off-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
diff --git a/net/slirp.c b/net/slirp.c
index 317cca7..7f846ec 100644
--- a/net/slirp.c
+++ b/net/slirp.c
@@ -472,7 +472,7 @@
if (s->smb_dir[0] != '\0') {
snprintf(cmd, sizeof(cmd), "rm -rf %s", s->smb_dir);
ret = system(cmd);
- if (!WIFEXITED(ret)) {
+ if (ret == -1 || !WIFEXITED(ret)) {
qemu_error("'%s' failed.\n", cmd);
} else if (WEXITSTATUS(ret)) {
qemu_error("'%s' failed. Error code: %d\n",