From: Jeremy Sowden Date: Sun, 20 Apr 2025 17:20:20 +0000 (+0100) Subject: IP2STR: correct address buffer size X-Git-Tag: ulogd-2.0.9~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a15dbac7026d5a2552054b0c186c221eb800e92c;p=thirdparty%2Fulogd2.git IP2STR: correct address buffer size The elements of the `ipstr_array` array are `IPADDR_LENGTH` bytes long where `IPADDR_LENGTH` is a local macro defined as 128. However, this is the number of bits in an IPv6 address, but the elements of `ipstr_array` only need to be big enough to be used for the output of `inet_ntop`. Use the standard `INET6_ADDRSTRLEN` macro instead. Signed-off-by: Jeremy Sowden Signed-off-by: Florian Westphal --- diff --git a/filter/ulogd_filter_IP2STR.c b/filter/ulogd_filter_IP2STR.c index 4d05368..c52824b 100644 --- a/filter/ulogd_filter_IP2STR.c +++ b/filter/ulogd_filter_IP2STR.c @@ -28,8 +28,6 @@ #include #include -#define IPADDR_LENGTH 128 - enum input_keys { KEY_OOB_FAMILY, KEY_OOB_PROTOCOL, @@ -137,7 +135,7 @@ static struct ulogd_key ip2str_keys[] = { }, }; -static char ipstr_array[MAX_KEY - START_KEY + 1][IPADDR_LENGTH]; +static char ipstr_array[MAX_KEY - START_KEY + 1][INET6_ADDRSTRLEN]; static int ip2str(struct ulogd_key *inp, int index, int oindex) {