comparison tcp-accept.c @ 1411:798854f62430 fuzz

merge from main
author Matt Johnston <matt@ucc.asn.au>
date Wed, 14 Jun 2017 23:31:42 +0800
parents ae6887d9ab46
children 58a74cb829b8
comparison
equal deleted inserted replaced
1408:27e65d3aed5f 1411:798854f62430
53 } 53 }
54 54
55 static void tcp_acceptor(struct Listener *listener, int sock) { 55 static void tcp_acceptor(struct Listener *listener, int sock) {
56 56
57 int fd; 57 int fd;
58 struct sockaddr_storage addr; 58 struct sockaddr_storage sa;
59 socklen_t len; 59 socklen_t len;
60 char ipstring[NI_MAXHOST], portstring[NI_MAXSERV]; 60 char ipstring[NI_MAXHOST], portstring[NI_MAXSERV];
61 struct TCPListener *tcpinfo = (struct TCPListener*)(listener->typedata); 61 struct TCPListener *tcpinfo = (struct TCPListener*)(listener->typedata);
62 62
63 len = sizeof(addr); 63 len = sizeof(sa);
64 64
65 fd = accept(sock, (struct sockaddr*)&addr, &len); 65 fd = accept(sock, (struct sockaddr*)&sa, &len);
66 if (fd < 0) { 66 if (fd < 0) {
67 return; 67 return;
68 } 68 }
69 69
70 if (getnameinfo((struct sockaddr*)&addr, len, ipstring, sizeof(ipstring), 70 if (getnameinfo((struct sockaddr*)&sa, len, ipstring, sizeof(ipstring),
71 portstring, sizeof(portstring), 71 portstring, sizeof(portstring),
72 NI_NUMERICHOST | NI_NUMERICSERV) != 0) { 72 NI_NUMERICHOST | NI_NUMERICSERV) != 0) {
73 m_close(fd); 73 m_close(fd);
74 return; 74 return;
75 } 75 }