fuzz: fix crash in newtcpdirect(), don't close the channel too early

This commit is contained in:
Matt Johnston
2021-03-05 22:51:11 +08:00
parent 3c2f113a78
commit d0d1ede191
3 changed files with 7 additions and 31 deletions

13
netio.c
View File

@@ -179,12 +179,6 @@ struct dropbear_progress_connection *connect_remote(const char* remotehost, cons
int err;
struct addrinfo hints;
#if DROPBEAR_FUZZ
if (fuzz.fuzzing) {
return fuzz_connect_remote(remotehost, remoteport, cb, cb_data, bind_address, bind_port);
}
#endif
c = m_malloc(sizeof(*c));
c->remotehost = m_strdup(remotehost);
c->remoteport = m_strdup(remoteport);
@@ -194,6 +188,13 @@ struct dropbear_progress_connection *connect_remote(const char* remotehost, cons
list_append(&ses.conn_pending, c);
#if DROPBEAR_FUZZ
if (fuzz.fuzzing) {
c->errstring = m_strdup("fuzzing connect_remote always fails");
return c;
}
#endif
memset(&hints, 0, sizeof(hints));
hints.ai_socktype = SOCK_STREAM;
hints.ai_family = AF_UNSPEC;