]> git.ipfire.org Git - thirdparty/ulogd2.git/commitdiff
IP2STR: correct address buffer size
authorJeremy Sowden <jeremy@azazel.net>
Sun, 20 Apr 2025 17:20:20 +0000 (18:20 +0100)
committerFlorian Westphal <fw@strlen.de>
Wed, 23 Apr 2025 11:52:56 +0000 (13:52 +0200)
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 <jeremy@azazel.net>
Signed-off-by: Florian Westphal <fw@strlen.de>
filter/ulogd_filter_IP2STR.c

index 4d0536817b6c567944831d450c68bb335ca6f80e..c52824b79e6589cede2a9e1b6aa00d2b9a3c2eca 100644 (file)
@@ -28,8 +28,6 @@
 #include <ulogd/ulogd.h>
 #include <netinet/if_ether.h>
 
-#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)
 {