From 3f88e5c64c17c12d5180b511f5a0b020347a598e Mon Sep 17 00:00:00 2001 From: Victor Julien Date: Sun, 9 Nov 2025 11:34:33 +0100 Subject: [PATCH] unix-socket/hostbits: fix ipv6 address parsing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In `add-hostbit`, `remove-hostbit` and `list-hostbit` commands, the IPv6 address parsing was not using the correct variable: from /usr/include/dirent.h:25, from suricata-common.h:73, from runmode-unix-socket.c:18: In function ‘inet_pton’, inlined from ‘UnixSocketHostbitAdd’ at runmode-unix-socket.c:1316:13: /usr/include/x86_64-linux-gnu/bits/inet-fortified.h:56:10: warning: call to ‘__inet_pton_chk_warn’ declared with attribute warning: inet_pton called with a destination buffer size too small [-Wattribute-warning] 56 | return __glibc_fortify (inet_pton, __sz, sizeof (char), | ^~~~~~~~~~~~~~~ In function ‘inet_pton’, inlined from ‘UnixSocketHostbitRemove’ at runmode-unix-socket.c:1403:13: /usr/include/x86_64-linux-gnu/bits/inet-fortified.h:56:10: warning: call to ‘__inet_pton_chk_warn’ declared with attribute warning: inet_pton called with a destination buffer size too small [-Wattribute-warning] 56 | return __glibc_fortify (inet_pton, __sz, sizeof (char), | ^~~~~~~~~~~~~~~ In function ‘inet_pton’, inlined from ‘UnixSocketHostbitList’ at runmode-unix-socket.c:1476:13: /usr/include/x86_64-linux-gnu/bits/inet-fortified.h:56:10: warning: call to ‘__inet_pton_chk_warn’ declared with attribute warning: inet_pton called with a destination buffer size too small [-Wattribute-warning] 56 | return __glibc_fortify (inet_pton, __sz, sizeof (char), | ^~~~~~~~~~~~~~~ Bug: #8102. (cherry picked from commit 874a0e8d3d63c8a13827832e90671c6af7ee4b37) --- src/runmode-unix-socket.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/runmode-unix-socket.c b/src/runmode-unix-socket.c index acdaf85775..c2405f0571 100644 --- a/src/runmode-unix-socket.c +++ b/src/runmode-unix-socket.c @@ -1313,7 +1313,7 @@ TmEcode UnixSocketHostbitAdd(json_t *cmd, json_t* answer, void *data_usused) if (inet_pton(AF_INET, ipaddress, &in) != 1) { uint32_t in6[4]; memset(&in6, 0, sizeof(in6)); - if (inet_pton(AF_INET6, ipaddress, &in) != 1) { + if (inet_pton(AF_INET6, ipaddress, &in6) != 1) { json_object_set_new(answer, "message", json_string("invalid address string")); return TM_ECODE_FAILED; } else { @@ -1400,7 +1400,7 @@ TmEcode UnixSocketHostbitRemove(json_t *cmd, json_t* answer, void *data_unused) if (inet_pton(AF_INET, ipaddress, &in) != 1) { uint32_t in6[4]; memset(&in6, 0, sizeof(in6)); - if (inet_pton(AF_INET6, ipaddress, &in) != 1) { + if (inet_pton(AF_INET6, ipaddress, &in6) != 1) { json_object_set_new(answer, "message", json_string("invalid address string")); return TM_ECODE_FAILED; } else { @@ -1473,7 +1473,7 @@ TmEcode UnixSocketHostbitList(json_t *cmd, json_t* answer, void *data_unused) if (inet_pton(AF_INET, ipaddress, &in) != 1) { uint32_t in6[4]; memset(&in6, 0, sizeof(in6)); - if (inet_pton(AF_INET6, ipaddress, &in) != 1) { + if (inet_pton(AF_INET6, ipaddress, &in6) != 1) { json_object_set_new(answer, "message", json_string("invalid address string")); return TM_ECODE_FAILED; } else {