From d7471c4f875a2be9dde4e65d06f71bf7c68d5ff5 Mon Sep 17 00:00:00 2001 From: Matt Johnston Date: Fri, 12 May 2017 22:14:49 +0800 Subject: notsocket changes from afl branch --HG-- branch : fuzz --- netio.c | 38 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) (limited to 'netio.c') diff --git a/netio.c b/netio.c index b16ba00..d7a0630 100644 --- a/netio.c +++ b/netio.c @@ -485,14 +485,36 @@ void get_socket_address(int fd, char **local_host, char **local_port, if (local_host || local_port) { addrlen = sizeof(addr); if (getsockname(fd, (struct sockaddr*)&addr, &addrlen) < 0) { - dropbear_exit("Failed socket address: %s", strerror(errno)); + if (errno == ENOTSOCK) { + // FUZZ + if (local_host) { + *local_host = m_strdup("notsocket"); + } + if (local_port) { + *local_port = m_strdup("999"); + } + return; + } else { + dropbear_exit("Failed socket address: %s", strerror(errno)); + } } getaddrstring(&addr, local_host, local_port, host_lookup); } if (remote_host || remote_port) { addrlen = sizeof(addr); if (getpeername(fd, (struct sockaddr*)&addr, &addrlen) < 0) { - dropbear_exit("Failed socket address: %s", strerror(errno)); + if (errno == ENOTSOCK) { + // FUZZ + if (remote_host) { + *remote_host = m_strdup("notsocket"); + } + if (remote_port) { + *remote_port = m_strdup("999"); + } + return; + } else { + dropbear_exit("Failed socket address: %s", strerror(errno)); + } } getaddrstring(&addr, remote_host, remote_port, host_lookup); } @@ -546,6 +568,18 @@ void getaddrstring(struct sockaddr_storage* addr, return; } else { /* if we can't do a numeric lookup, something's gone terribly wrong */ + if (ret == EAI_FAMILY) { + // FUZZ + // Fake it for non-socket input + if (ret_host) { + *ret_host = m_strdup("0.0.0.0"); + } + if (ret_port) + { + *ret_port = m_strdup("999"); + } + return; + } dropbear_exit("Failed lookup: %s", gai_strerror(ret)); } } -- cgit v1.2.3