From: Rasmus Villemoes Date: Tue, 8 Mar 2016 20:40:51 +0000 (-0300) Subject: [media] drivers/media/pci/zoran: avoid fragile snprintf use X-Git-Tag: v4.7~34^2~34 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e57b36c0c46d7288d6d5bd602003b8fcd17efe3f;p=platform%2Fkernel%2Flinux-exynos.git [media] drivers/media/pci/zoran: avoid fragile snprintf use Appending to a string by doing snprintf(buf, bufsize, "%s...", buf, ...) is not guaranteed to work. Signed-off-by: Rasmus Villemoes Signed-off-by: Mauro Carvalho Chehab --- diff --git a/drivers/media/pci/zoran/videocodec.c b/drivers/media/pci/zoran/videocodec.c index c010716..13a3c07 100644 --- a/drivers/media/pci/zoran/videocodec.c +++ b/drivers/media/pci/zoran/videocodec.c @@ -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) {