[media] drivers/media/pci/zoran: avoid fragile snprintf use
authorRasmus Villemoes <linux@rasmusvillemoes.dk>
Tue, 8 Mar 2016 20:40:51 +0000 (17:40 -0300)
committerMauro Carvalho Chehab <mchehab@osg.samsung.com>
Sat, 7 May 2016 13:27:07 +0000 (10:27 -0300)
Appending to a string by doing snprintf(buf, bufsize, "%s...", buf,
...) is not guaranteed to work.

Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
drivers/media/pci/zoran/videocodec.c

index c010716..13a3c07 100644 (file)
@@ -116,8 +116,9 @@ videocodec_attach (struct videocodec_master *master)
                                goto out_module_put;
                        }
 
-                       snprintf(codec->name, sizeof(codec->name),
-                                "%s[%d]", codec->name, h->attached);
+                       res = strlen(codec->name);
+                       snprintf(codec->name + res, sizeof(codec->name) - res,
+                                "[%d]", h->attached);
                        codec->master_data = master;
                        res = codec->setup(codec);
                        if (res == 0) {