Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1647369

[PATCH] arch: blackfin: kernel: bfin_gpio: Use strlcpy to Copy a C-string into a sized buffer

From Karim Eshapa <karim.eshapa@gmail.com>
Newsgroups linux.kernel
Subject [PATCH] arch: blackfin: kernel: bfin_gpio: Use strlcpy to Copy a C-string into a sized buffer
Date 2017-05-22 22:50 +0200
Message-ID <tK2r7-1WA-11@gated-at.bofh.it> (permalink)
Organization linux.* mail to news gateway

Show all headers | View raw


Use strlcpy with sized buffer instead of strncpy to
avoid non NUL-terminated source strings problems.

Signed-off-by: Karim Eshapa <karim.eshapa@gmail.com>
---
 arch/blackfin/kernel/bfin_gpio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/blackfin/kernel/bfin_gpio.c b/arch/blackfin/kernel/bfin_gpio.c
index c5d3128..49fca59 100644
--- a/arch/blackfin/kernel/bfin_gpio.c
+++ b/arch/blackfin/kernel/bfin_gpio.c
@@ -119,7 +119,7 @@ static void gpio_error(unsigned gpio)
 static void set_label(unsigned short ident, const char *label)
 {
 	if (label) {
-		strncpy(str_ident[ident].name, label,
+		strlcpy(str_ident[ident].name, label,
 			 RESOURCE_LABEL_SIZE);
 		str_ident[ident].name[RESOURCE_LABEL_SIZE - 1] = 0;
 	}
-- 
2.7.4

Back to linux.kernel | Previous | Next | Find similar | Unroll thread


Thread

[PATCH] arch: blackfin: kernel: bfin_gpio: Use strlcpy to Copy a C-string into a sized buffer Karim Eshapa <karim.eshapa@gmail.com> - 2017-05-22 22:50 +0200

csiph-web