mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
To: Bryan Wu <cooloney@gmail.com>, Richard Purdie <rpurdie@rpsys.net>,
	linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org,
	Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
Subject: [PATCH 1/3] leds/class: Use strlcpy instead of strncpy
Date: Mon, 30 Mar 2015 10:55:10 +0200	[thread overview]
Message-ID: <1427705712-18083-2-git-send-email-ricardo.ribalda@gmail.com> (raw)
In-Reply-To: <1427705712-18083-1-git-send-email-ricardo.ribalda@gmail.com>

Strncpy does not guarantee a zero terminated string. Use strlcpy
instead.

Reported-by: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
---
 drivers/leds/led-class.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/leds/led-class.c b/drivers/leds/led-class.c
index ebf6dad4f..294d6d6 100644
--- a/drivers/leds/led-class.c
+++ b/drivers/leds/led-class.c
@@ -224,7 +224,7 @@ static int led_classdev_next_name(const char *init_name, char *name,
 {
 	int i = 0;
 
-	strncpy(name, init_name, len);
+	strlcpy(name, init_name, len);
 
 	while (class_find_device(leds_class, NULL, name, match_name))
 		snprintf(name, len, "%s_%d", init_name, ++i);
-- 
2.1.4


  reply	other threads:[~2015-03-30  8:56 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-30  8:55 [PATCH 0/3] leds/class: Fix string handling Ricardo Ribalda Delgado
2015-03-30  8:55 ` Ricardo Ribalda Delgado [this message]
2015-03-30  8:55 ` [PATCH 2/3] leds/class: Check snprintf return value Ricardo Ribalda Delgado
2015-03-30  8:59   ` Geert Uytterhoeven
2015-03-30  8:55 ` [PATCH 3/3] leds/class: Set naming index as unsigned Ricardo Ribalda Delgado
2015-03-30  8:59   ` Geert Uytterhoeven
2015-03-30 17:15 ` [PATCH 0/3] leds/class: Fix string handling Bryan Wu
2015-03-30 17:46   ` Ricardo Ribalda Delgado
2015-03-30 18:11     ` Bryan Wu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1427705712-18083-2-git-send-email-ricardo.ribalda@gmail.com \
    --to=ricardo.ribalda@gmail.com \
    --cc=cooloney@gmail.com \
    --cc=geert@linux-m68k.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-leds@vger.kernel.org \
    --cc=rpurdie@rpsys.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®