]> git.ipfire.org Git - thirdparty/ulogd2.git/commitdiff
sqlite3: insert ipv6 addresses as null rather than garbage
authorJeremy Sowden <jeremy@azazel.net>
Mon, 21 Aug 2023 19:42:36 +0000 (20:42 +0100)
committerFlorian Westphal <fw@strlen.de>
Thu, 14 Sep 2023 12:22:49 +0000 (14:22 +0200)
Currently, the plug-in assumes that all IP addresses are 32-bit ipv4
addresses, so ipv6 addresses get truncated and inserted as garbage.
Insert nulls instead.

Signed-off-by: Jeremy Sowden <jeremy@azazel.net>
Signed-off-by: Florian Westphal <fw@strlen.de>
output/sqlite3/ulogd_output_SQLITE3.c

index 3a823892a2dd56282353669957dfeae259c82db5..6aeb7a3865e1b66d91e8ca4e632c4aae40a7e423 100644 (file)
@@ -33,6 +33,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <arpa/inet.h>
+#include <netinet/in.h>
 #include <ulogd/ulogd.h>
 #include <ulogd/conffile.h>
 #include <sqlite3.h>
@@ -178,7 +179,11 @@ sqlite3_interp(struct ulogd_pluginstance *pi)
                        break;
 
                case ULOGD_RET_IPADDR:
-                       ret = sqlite3_bind_int(priv->p_stmt, i, k_ret->u.value.ui32);
+                       if (k_ret->len == sizeof(struct in_addr))
+                               ret = sqlite3_bind_int(priv->p_stmt, i,
+                                                      k_ret->u.value.ui32);
+                       else
+                               ret = sqlite3_bind_null(priv->p_stmt, i);
                        break;
 
                case ULOGD_RET_UINT64: