* [PATCH] [media] rainshadow-cec: use strlcat instead of strncat
@ 2017-04-19 17:15 Arnd Bergmann
2017-04-19 21:14 ` Hans Verkuil
0 siblings, 1 reply; 3+ messages in thread
From: Arnd Bergmann @ 2017-04-19 17:15 UTC (permalink / raw)
To: Hans Verkuil, Mauro Carvalho Chehab
Cc: Arnd Bergmann, linux-media, linux-kernel
gcc warns about an obviously incorrect use of strncat():
drivers/media/usb/rainshadow-cec/rainshadow-cec.c: In function 'rain_cec_adap_transmit':
drivers/media/usb/rainshadow-cec/rainshadow-cec.c:299:4: error: specified bound 48 equals the size of the destination [-Werror=stringop-overflow=]
It seems that strlcat was intended here, and using that makes the
code correct.
Fixes: 0f314f6c2e77 ("[media] rainshadow-cec: new RainShadow Tech HDMI CEC driver")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
drivers/media/usb/rainshadow-cec/rainshadow-cec.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/media/usb/rainshadow-cec/rainshadow-cec.c b/drivers/media/usb/rainshadow-cec/rainshadow-cec.c
index 541ca543f71f..dc1f64f904cd 100644
--- a/drivers/media/usb/rainshadow-cec/rainshadow-cec.c
+++ b/drivers/media/usb/rainshadow-cec/rainshadow-cec.c
@@ -296,7 +296,7 @@ static int rain_cec_adap_transmit(struct cec_adapter *adap, u8 attempts,
cec_msg_destination(msg), msg->msg[1]);
for (i = 2; i < msg->len; i++) {
snprintf(hex, sizeof(hex), "%02x", msg->msg[i]);
- strncat(cmd, hex, sizeof(cmd));
+ strlcat(cmd, hex, sizeof(cmd));
}
}
mutex_lock(&rain->write_lock);
--
2.9.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] [media] rainshadow-cec: use strlcat instead of strncat
2017-04-19 17:15 [PATCH] [media] rainshadow-cec: use strlcat instead of strncat Arnd Bergmann
@ 2017-04-19 21:14 ` Hans Verkuil
2017-04-19 22:15 ` Arnd Bergmann
0 siblings, 1 reply; 3+ messages in thread
From: Hans Verkuil @ 2017-04-19 21:14 UTC (permalink / raw)
To: Arnd Bergmann, Mauro Carvalho Chehab; +Cc: linux-media, linux-kernel
On 19/04/17 19:15, Arnd Bergmann wrote:
> gcc warns about an obviously incorrect use of strncat():
>
> drivers/media/usb/rainshadow-cec/rainshadow-cec.c: In function 'rain_cec_adap_transmit':
> drivers/media/usb/rainshadow-cec/rainshadow-cec.c:299:4: error: specified bound 48 equals the size of the destination [-Werror=stringop-overflow=]
>
> It seems that strlcat was intended here, and using that makes the
> code correct.
Oops! You're right, it should be strlcat.
Which gcc version do you use? Mine (6.3.0) didn't give an error (or warning, for that matter).
Regards,
Hans
>
> Fixes: 0f314f6c2e77 ("[media] rainshadow-cec: new RainShadow Tech HDMI CEC driver")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
> drivers/media/usb/rainshadow-cec/rainshadow-cec.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/media/usb/rainshadow-cec/rainshadow-cec.c b/drivers/media/usb/rainshadow-cec/rainshadow-cec.c
> index 541ca543f71f..dc1f64f904cd 100644
> --- a/drivers/media/usb/rainshadow-cec/rainshadow-cec.c
> +++ b/drivers/media/usb/rainshadow-cec/rainshadow-cec.c
> @@ -296,7 +296,7 @@ static int rain_cec_adap_transmit(struct cec_adapter *adap, u8 attempts,
> cec_msg_destination(msg), msg->msg[1]);
> for (i = 2; i < msg->len; i++) {
> snprintf(hex, sizeof(hex), "%02x", msg->msg[i]);
> - strncat(cmd, hex, sizeof(cmd));
> + strlcat(cmd, hex, sizeof(cmd));
> }
> }
> mutex_lock(&rain->write_lock);
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] [media] rainshadow-cec: use strlcat instead of strncat
2017-04-19 21:14 ` Hans Verkuil
@ 2017-04-19 22:15 ` Arnd Bergmann
0 siblings, 0 replies; 3+ messages in thread
From: Arnd Bergmann @ 2017-04-19 22:15 UTC (permalink / raw)
To: Hans Verkuil
Cc: Mauro Carvalho Chehab, linux-media, Linux Kernel Mailing List
On Wed, Apr 19, 2017 at 11:14 PM, Hans Verkuil <hverkuil@xs4all.nl> wrote:
> On 19/04/17 19:15, Arnd Bergmann wrote:
>> gcc warns about an obviously incorrect use of strncat():
>>
>> drivers/media/usb/rainshadow-cec/rainshadow-cec.c: In function 'rain_cec_adap_transmit':
>> drivers/media/usb/rainshadow-cec/rainshadow-cec.c:299:4: error: specified bound 48 equals the size of the destination [-Werror=stringop-overflow=]
>>
>> It seems that strlcat was intended here, and using that makes the
>> code correct.
>
> Oops! You're right, it should be strlcat.
>
> Which gcc version do you use? Mine (6.3.0) didn't give an error (or warning, for that matter).
I think the warning was only added in gcc-7.0.1.
Arnd
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-04-19 22:15 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-19 17:15 [PATCH] [media] rainshadow-cec: use strlcat instead of strncat Arnd Bergmann
2017-04-19 21:14 ` Hans Verkuil
2017-04-19 22:15 ` Arnd Bergmann
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).