aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHans Verkuil <hverkuil@xs4all.nl>2021-06-12 11:47:26 +0200
committerHans Verkuil <hverkuil-cisco@xs4all.nl>2021-09-01 17:00:28 +0200
commitdbdc39081994e921a5644e7f10c54b378fdd0085 (patch)
tree6479e33e2aa8a32d3a92266f509a013b80c87e9d
parent787434a789f3413f0aff054af883ae2b632ffcdb (diff)
v4l-utils: libdvbv5: fix broken my_strlcpy calls
sizeof(*msg->cmd) should have been sizeof(msg->cmd). Also, call strncpy with siz - 1 instead of siz to avoid this compiler warning: CC libdvbv5_la-dvb-dev-remote.lo In function ‘my_strlcpy’, inlined from ‘send_buf.isra.0.constprop’ at dvb-dev-remote.c:350:2: dvb-dev-remote.c:121:7: warning: ‘strncpy’ output truncated copying 1 byte from a string of length 12 [-Wstringop-truncation] 121 | rc = strncpy(dst, src, siz); | ^~~~~~~~~~~~~~~~~~~~~~ Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
-rw-r--r--lib/libdvbv5/dvb-dev-remote.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/libdvbv5/dvb-dev-remote.c b/lib/libdvbv5/dvb-dev-remote.c
index fa551b82..3ef9d67c 100644
--- a/lib/libdvbv5/dvb-dev-remote.c
+++ b/lib/libdvbv5/dvb-dev-remote.c
@@ -118,7 +118,7 @@ static char *my_strlcpy(char *dst, const char *src, size_t siz)
{
char *rc;
- rc = strncpy(dst, src, siz);
+ rc = strncpy(dst, src, siz - 1);
dst[siz - 1] = '\0';
return rc;
@@ -251,7 +251,7 @@ static struct queued_msg *send_fmt(struct dvb_device_priv *dvb, int fd,
pthread_mutex_init(&msg->lock, NULL);
pthread_cond_init(&msg->cond, NULL);
- my_strlcpy(msg->cmd, cmd, sizeof(*msg->cmd));
+ my_strlcpy(msg->cmd, cmd, sizeof(msg->cmd));
pthread_mutex_lock(&priv->lock_io);
msg->seq = ++priv->seq;
@@ -347,7 +347,7 @@ static struct queued_msg *send_buf(struct dvb_device_priv *dvb, int fd,
pthread_mutex_init(&msg->lock, NULL);
pthread_cond_init(&msg->cond, NULL);
- my_strlcpy(msg->cmd, cmd, sizeof(*msg->cmd));
+ my_strlcpy(msg->cmd, cmd, sizeof(msg->cmd));
pthread_mutex_lock(&priv->lock_io);
msg->seq = ++priv->seq;

Privacy Policy