mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] drm/nouveau/core/client: use strlcpy() instead of strncpy()
@ 2018-01-12  8:03 Xiongfeng Wang
  0 siblings, 0 replies; only message in thread
From: Xiongfeng Wang @ 2018-01-12  8:03 UTC (permalink / raw)
  To: airlied, dri-devel, nouveau, linux-kernel; +Cc: arnd, wangxiongfeng2

From: Xiongfeng Wang <xiongfeng.wang@linaro.org>

gcc-8 reports

drivers/gpu/drm/nouveau/nvif/client.c: In function 'nvif_client_init':
./include/linux/string.h:245:9: warning: '__builtin_strncpy' specified
bound 32 equals destination size [-Wstringop-truncation]

We need to use strlcpy() to make sure the dest string is nul-terminated.

Signed-off-by: Xiongfeng Wang <xiongfeng.wang@linaro.org>
---
 drivers/gpu/drm/nouveau/nvif/client.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/nouveau/nvif/client.c b/drivers/gpu/drm/nouveau/nvif/client.c
index 12db549..f294d99 100644
--- a/drivers/gpu/drm/nouveau/nvif/client.c
+++ b/drivers/gpu/drm/nouveau/nvif/client.c
@@ -69,7 +69,7 @@
 	} nop = {};
 	int ret;
 
-	strncpy(args.name, name, sizeof(args.name));
+	strlcpy(args.name, name, sizeof(args.name));
 	ret = nvif_object_init(parent != client ? &parent->object : NULL,
 			       0, NVIF_CLASS_CLIENT, &args, sizeof(args),
 			       &client->object);
-- 
1.8.3.1

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2018-01-12  7:57 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-12  8:03 [PATCH] drm/nouveau/core/client: use strlcpy() instead of strncpy() Xiongfeng Wang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®