diff options
author | Rasmus Villemoes <linux@rasmusvillemoes.dk> | 2016-03-08 21:40:53 +0100 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@osg.samsung.com> | 2016-05-07 15:27:16 +0200 |
commit | 869f076bd68b27e0990e3fc5036a8eb571014473 (patch) | |
tree | 1b1f0b233d468458e54a9b660b25a96d35b2ff7a | |
parent | [media] drivers/media/pci/zoran: avoid fragile snprintf use (diff) | |
download | linux-869f076bd68b27e0990e3fc5036a8eb571014473.tar.xz linux-869f076bd68b27e0990e3fc5036a8eb571014473.zip |
[media] ati_remote: avoid fragile snprintf use
Passing overlapping source and destination to snprintf is
fragile. Replace with a single (mostly) equivalent call. If one wants
to preserve the space preceding udev->product whether or not there was
a manufacturer, just remove udev->manufacturer from the && expression.
Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
-rw-r--r-- | drivers/media/rc/ati_remote.c | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/drivers/media/rc/ati_remote.c b/drivers/media/rc/ati_remote.c index 3f61d77d4147..9f5b59706741 100644 --- a/drivers/media/rc/ati_remote.c +++ b/drivers/media/rc/ati_remote.c @@ -873,13 +873,10 @@ static int ati_remote_probe(struct usb_interface *interface, strlcat(ati_remote->rc_phys, "/input0", sizeof(ati_remote->rc_phys)); strlcat(ati_remote->mouse_phys, "/input1", sizeof(ati_remote->mouse_phys)); - if (udev->manufacturer) - strlcpy(ati_remote->rc_name, udev->manufacturer, - sizeof(ati_remote->rc_name)); - - if (udev->product) - snprintf(ati_remote->rc_name, sizeof(ati_remote->rc_name), - "%s %s", ati_remote->rc_name, udev->product); + snprintf(ati_remote->rc_name, sizeof(ati_remote->rc_name), "%s%s%s", + udev->manufacturer ?: "", + udev->manufacturer && udev->product ? " " : "", + udev->product ?: ""); if (!strlen(ati_remote->rc_name)) snprintf(ati_remote->rc_name, sizeof(ati_remote->rc_name), |