# HG changeset patch # User Matt Johnston # Date 1494598489 -28800 # Node ID 78b7e063411725be63c5b5e0f4618ab371d0c145 # Parent 0ed3d2bbf956cb8a9bf0f4b5a86b7dd9688205cb notsocket changes from afl branch diff -r 0ed3d2bbf956 -r 78b7e0634117 netio.c --- a/netio.c Thu Jul 21 23:16:57 2016 +0800 +++ b/netio.c Fri May 12 22:14:49 2017 +0800 @@ -485,14 +485,36 @@ 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 @@ 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)); } }