]> git.ipfire.org Git - thirdparty/ulogd2.git/commitdiff
db: simplify initialization of ring-buffer
authorJeremy Sowden <jeremy@azazel.net>
Tue, 30 Nov 2021 10:55:54 +0000 (10:55 +0000)
committerPablo Neira Ayuso <pablo@netfilter.org>
Mon, 3 Jan 2022 15:40:50 +0000 (16:40 +0100)
Currently, `strncpy` is used to copy the SQL statement to the ring
buffer, passing the length of the source string, which leads gcc to
complain:

  ../../util/db.c:231:25: warning: `strncpy` specified bound depends on the length of the source argument

In fact, the ring buffer is sized to be a multiple of the size of the
SQL buffer, and the SQL is simply copied multiple times at increasing
offsets, so use `strcpy` instead.

Signed-off-by: Jeremy Sowden <jeremy@azazel.net>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
util/db.c

index 339e39ef47973dfb6188d0079ab11fc45d3b4628..c1d24365239fe5f9439e2b6310934aa6eb8d7336 100644 (file)
--- a/util/db.c
+++ b/util/db.c
@@ -228,9 +228,8 @@ int ulogd_db_start(struct ulogd_pluginstance *upi)
                          di->ring.size, di->ring.length);
                /* init start of query for each element */
                for(i = 0; i < di->ring.size; i++) {
-                       strncpy(di->ring.ring + di->ring.length * i + 1,
-                               di->stmt,
-                               strlen(di->stmt));
+                       strcpy(di->ring.ring + di->ring.length * i + 1,
+                              di->stmt);
                }
                /* init cond & mutex */
                ret = pthread_cond_init(&di->ring.cond, NULL);