diff mbox series

[ulogd2,v3,24/30] db: replace `strncpy` with `strcpy`

Message ID 20211124222444.2597311-36-jeremy@azazel.net
State Changes Requested
Delegated to: Pablo Neira
Headers show
Series None | expand

Commit Message

Jeremy Sowden Nov. 24, 2021, 10:24 p.m. UTC
We used strncpy to copy the SQL statement to the ring buffer, passing
the length of the source string, which led the compiler 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 we are just copying the SQL multiple times at various
offsets, so we can just use `strcpy` instead.

Signed-off-by: Jeremy Sowden <jeremy@azazel.net>
---
 util/db.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/util/db.c b/util/db.c
index 339e39ef4797..c1d24365239f 100644
--- 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);