Skip to content

Commit 8f1d355

Browse files
authored
Merge pull request #67 from ADTRAN/ipv6_addr_len_fix
provide correct address length for inet_ntop i.o. to avoid error ENOSPC
2 parents 1b1d2a5 + 740c22f commit 8f1d355

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

src/session_server.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -369,9 +369,9 @@ nc_sock_accept_binds(struct nc_bind *binds, uint16_t bind_count, int timeout, ch
369369
/* host was requested */
370370
if (host) {
371371
if (saddr.ss_family == AF_INET) {
372-
*host = malloc(15);
372+
*host = malloc(INET_ADDRSTRLEN);
373373
if (*host) {
374-
if (!inet_ntop(AF_INET, &((struct sockaddr_in *)&saddr)->sin_addr.s_addr, *host, 15)) {
374+
if (!inet_ntop(AF_INET, &((struct sockaddr_in *)&saddr)->sin_addr.s_addr, *host, INET_ADDRSTRLEN)) {
375375
ERR("inet_ntop failed (%s).", strerror(errno));
376376
free(*host);
377377
*host = NULL;
@@ -386,7 +386,7 @@ nc_sock_accept_binds(struct nc_bind *binds, uint16_t bind_count, int timeout, ch
386386
} else if (saddr.ss_family == AF_INET6) {
387387
*host = malloc(INET6_ADDRSTRLEN);
388388
if (*host) {
389-
if (!inet_ntop(AF_INET6, ((struct sockaddr_in6 *)&saddr)->sin6_addr.s6_addr, *host, 40)) {
389+
if (!inet_ntop(AF_INET6, ((struct sockaddr_in6 *)&saddr)->sin6_addr.s6_addr, *host, INET6_ADDRSTRLEN)) {
390390
ERR("inet_ntop failed (%s).", strerror(errno));
391391
free(*host);
392392
*host = NULL;

0 commit comments

Comments
 (0)