IPv6 fixes for incoming inetd calls, minors from lint

master^2
Alexey Khromov 5 months ago
parent 3526bc5ece
commit 9aed37b92e

@ -54,7 +54,6 @@ static int tcpip_connect2(struct addrinfo *ai)
if ( fd == -1 )
{
DEB((D_INFO, "tcpip_connect2: socket error"));
continue;
}
else break;

@ -118,6 +118,9 @@ int tio_get(int fd, TIO *tio)
{
#ifdef HAVE_TERMIOS_H
return tcgetattr(fd, tio);
#else
DEB(("io_unix_tio: TERMIOS not supported!"));
return -1;
#endif
}
@ -127,6 +130,9 @@ int tio_set(int fd, TIO *tio)
{
#ifdef HAVE_TERMIOS_H
return tcsetattr(fd, TCSANOW, tio);
#else
DEB(("io_unix_tio: TERMIOS not supported!"));
return -1;
#endif
}

@ -788,7 +788,7 @@ case BPMSG_FILE: /* File information */
DEB((D_24554, "no, skipping; TODO: accept it"));
if( bstate->extracmd[0] != -1 ) return 0;
bstate->extracmd[0] = BPMSG_SKIP;
sprintf(bstate->extracmd+1, "%s %ld %ld %ld", recvfi.fn, recvfi.sz, recvfi.tm);
sprintf(bstate->extracmd+1, "%s %ld %ld %ld", recvfi.fn, recvfi.sz, recvfi.tm, recvfi.offs);
bstate->extraislast = false;
return 1;
}

@ -22,8 +22,11 @@
int answ_system(e_session type, char *connstr, int inetd)
{
TIO oldtio;
struct sockaddr_in client;
struct sockaddr_storage client;
int clientlen = sizeof(client);
char clienthost[NI_MAXHOST];
char clientport[NI_MAXSERV];
int clientres = 0;
int rc = 0;
char *p;
@ -74,18 +77,18 @@ int answ_system(e_session type, char *connstr, int inetd)
log("Answering TCPIP call...");
if( connstr && *connstr )
state.connstr = (char*)xstrcpy(connstr);
else if( getpeername(0, (struct sockaddr*)&client, &clientlen) == -1 )
logerr("can't get client address");
else
{
#ifdef IPV6
>char addr_str[INET6_ADDRSTRLEN+1];
state.peername = (char*)xstrcpy(inet_ntop(AF_INET6, client.sin6_addr, addr_str, INET6_ADDRSTRLEN));
state.peerport = (long)ntohs(client.sin6_port);
#else
state.peername = (char*)xstrcpy(inet_ntoa(client.sin_addr));
state.peerport = (long)ntohs(client.sin_port);
#endif
clientres = getnameinfo( (struct sockaddr*)&client, clientlen,
clienthost, sizeof(clienthost), clientport,
sizeof(clientport), NI_NUMERICHOST | NI_NUMERICSERV);
if ( clientres == 0 )
{
state.peername = (char*)xstrcpy(clienthost);
state.peerport = (long)atol(clientport);
}
else
log("sess_answ: can't get client address: ", gai_strerror(clientres));
}
}

@ -81,6 +81,7 @@ void *xrealloc(void *buf, size_t size)
else if( (tmp = (char*)(buf ? realloc(buf, size) : malloc(size))) == NULL )
{
log("failed to reallocate %ld bytes -> abort", size);
if( buf ) free(buf);
abort();
}

Loading…
Cancel
Save