From 10a95be23ce1d5c3901eff98953f545ee3267fc5 Mon Sep 17 00:00:00 2001 From: satbir Date: Mon, 2 Jul 2018 16:39:28 +0530 Subject: [PATCH 1/2] [TA1487] Passing correct size to getnameinfo() Signed-off-by: satbir --- lib/libzrepl/data_conn.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/libzrepl/data_conn.c b/lib/libzrepl/data_conn.c index e696d341d19c..f80bf61b9349 100644 --- a/lib/libzrepl/data_conn.c +++ b/lib/libzrepl/data_conn.c @@ -725,9 +725,9 @@ uzfs_zvol_io_conn_acceptor(void *arg) #ifdef DEBUG hbuf = kmem_alloc(sizeof (NI_MAXHOST), KM_SLEEP); sbuf = kmem_alloc(sizeof (NI_MAXSERV), KM_SLEEP); - rc = getnameinfo(&in_addr, in_len, hbuf, sizeof (hbuf), - sbuf, sizeof (sbuf), NI_NUMERICHOST | - NI_NUMERICSERV); + rc = getnameinfo(&in_addr, in_len, hbuf, + sizeof (NI_MAXHOST), sbuf, sizeof (NI_MAXSERV), + NI_NUMERICHOST | NI_NUMERICSERV); if (rc == 0) { LOG_DEBUG("Accepted connection from %s:%s", hbuf, sbuf); From 35dd949e794cc693ca8166ca9c160e8af4ec583d Mon Sep 17 00:00:00 2001 From: satbir Date: Mon, 2 Jul 2018 17:54:07 +0530 Subject: [PATCH 2/2] Changed code as per comments received. Signed-off-by: satbir --- lib/libzrepl/data_conn.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/libzrepl/data_conn.c b/lib/libzrepl/data_conn.c index f80bf61b9349..498690b591fd 100644 --- a/lib/libzrepl/data_conn.c +++ b/lib/libzrepl/data_conn.c @@ -723,18 +723,18 @@ uzfs_zvol_io_conn_acceptor(void *arg) continue; } #ifdef DEBUG - hbuf = kmem_alloc(sizeof (NI_MAXHOST), KM_SLEEP); - sbuf = kmem_alloc(sizeof (NI_MAXSERV), KM_SLEEP); + hbuf = kmem_alloc(NI_MAXHOST, KM_SLEEP); + sbuf = kmem_alloc(NI_MAXSERV, KM_SLEEP); rc = getnameinfo(&in_addr, in_len, hbuf, - sizeof (NI_MAXHOST), sbuf, sizeof (NI_MAXSERV), + NI_MAXHOST, sbuf, NI_MAXSERV, NI_NUMERICHOST | NI_NUMERICSERV); if (rc == 0) { LOG_DEBUG("Accepted connection from %s:%s", hbuf, sbuf); } - kmem_free(hbuf, sizeof (NI_MAXHOST)); - kmem_free(sbuf, sizeof (NI_MAXSERV)); + kmem_free(hbuf, NI_MAXHOST); + kmem_free(sbuf, NI_MAXSERV); #endif if (events[i].data.fd == io_sfd) { LOG_INFO("Connection req for data IO");