http: avoid use of uninitialized value for AF_UNIX/AF_LOCAL sockaddr

unixsock peer does not have sun_path initialized.
This commit is contained in:
Azat Khuzhin 2019-05-12 15:19:31 +03:00
parent 737d1beb14
commit ad51a3c1ba
No known key found for this signature in database
GPG Key ID: B86086848EF8686D

18
http.c
View File

@ -51,9 +51,16 @@
#ifndef _WIN32
#include <sys/socket.h>
#include <sys/stat.h>
#else
#else /* _WIN32 */
#include <winsock2.h>
#include <ws2tcpip.h>
#endif /* _WIN32 */
#ifdef EVENT__HAVE_SYS_UN_H
#include <sys/un.h>
#endif
#ifdef EVENT__HAVE_AFUNIX_H
#include <afunix.h>
#endif
#include <sys/queue.h>
@ -78,7 +85,7 @@
#include <string.h>
#ifndef _WIN32
#include <syslog.h>
#endif
#endif /* !_WIN32 */
#include <signal.h>
#ifdef EVENT__HAVE_UNISTD_H
#include <unistd.h>
@ -4421,6 +4428,13 @@ evhttp_get_request_connection(
char *hostname = NULL, *portname = NULL;
struct bufferevent* bev = NULL;
#ifdef EVENT__HAVE_STRUCT_SOCKADDR_UN
if (sa->sa_family == AF_UNIX) {
struct sockaddr_un *sun = (struct sockaddr_un *)sa;
sun->sun_path[0] = '\0';
}
#endif
name_from_addr(sa, salen, &hostname, &portname);
if (hostname == NULL || portname == NULL) {
if (hostname) mm_free(hostname);