summaryrefslogtreecommitdiffhomepage
path: root/fuzz/fuzz-common.c
diff options
context:
space:
mode:
authorMatt Johnston <matt@ucc.asn.au>2021-03-06 22:58:57 +0800
committerMatt Johnston <matt@ucc.asn.au>2021-03-06 22:58:57 +0800
commitd2bfa6aedcdf8f8de2f8acf47ff02845d44714b0 (patch)
tree7dee01fbf7646d500b1e811c149826572afd6434 /fuzz/fuzz-common.c
parentd0d1ede191cbc8dfa1748990a052ef90f000b55b (diff)
fuzz: handle errors from wrapfd_new_dummy()
Diffstat (limited to 'fuzz/fuzz-common.c')
-rw-r--r--fuzz/fuzz-common.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/fuzz/fuzz-common.c b/fuzz/fuzz-common.c
index c9a3391..00b0606 100644
--- a/fuzz/fuzz-common.c
+++ b/fuzz/fuzz-common.c
@@ -230,10 +230,19 @@ int fuzz_spawn_command(int *ret_writefd, int *ret_readfd, int *ret_errfd, pid_t
if (ret_errfd) {
*ret_errfd = wrapfd_new_dummy();
}
- *ret_pid = 999;
- return DROPBEAR_SUCCESS;
-}
+ if (*ret_writefd == -1 || *ret_readfd == -1 || (ret_errfd && *ret_errfd == -1)) {
+ m_close(*ret_writefd);
+ m_close(*ret_readfd);
+ if (ret_errfd) {
+ m_close(*ret_errfd);
+ }
+ return DROPBEAR_FAILURE;
+ } else {
+ *ret_pid = 999;
+ return DROPBEAR_SUCCESS;
+ }
+}
/* Fake dropbear_listen, always returns failure for now.
TODO make it sometimes return success with wrapfd_new_dummy() sockets.