public inbox for netdev@vger.kernel.org 
 help / color / mirror / Atom feed
From: Chen Gang <gang.chen-bOixZGp5f+dBDgjK7y7TUQ@public•gmane.org>
To: Stanislaw Gruszka
	<sgruszka-H+wXaHxf7aLQT0dZR+AlfA@public•gmane.org>,
	"John W. Linville"
	<linville-2XuSBdqkA4R54TAoqtyWWQ@public•gmane.org>
Cc: linux-wireless-u79uwXL29TY76Z2rM5mHXA@public•gmane.org,
	netdev <netdev-u79uwXL29TY76Z2rM5mHXA@public•gmane.org>
Subject: [PATCH] drivers/net/wireless/iwlegacy: adding check length for parameter buf
Date: Sun, 20 Jan 2013 17:53:54 +0800	[thread overview]
Message-ID: <50FBBEB2.2000306@asianux.com> (raw)


  the parameter 'const char *buf' may be not '\0' based string.
  so need check the length before use it.

additinal info:
  originally, it had the relative checking.
  but it was deleted when fix another issues (using strlcpy instead of
strncpy)
  and now, we need restore the checking (but still keep strlcpy)

Signed-off-by: Chen Gang <gang.chen-bOixZGp5f+dBDgjK7y7TUQ@public•gmane.org>
---
 drivers/net/wireless/iwlegacy/3945-mac.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/wireless/iwlegacy/3945-mac.c
b/drivers/net/wireless/iwlegacy/3945-mac.c
index 050ce7c..71cdbac 100644
--- a/drivers/net/wireless/iwlegacy/3945-mac.c
+++ b/drivers/net/wireless/iwlegacy/3945-mac.c
@@ -3273,7 +3273,7 @@ il3945_store_measurement(struct device *d, struct
device_attribute *attr,

 	if (count) {
 		char *p = buffer;
-		strlcpy(buffer, buf, sizeof(buffer));
+		strlcpy(buffer, buf, min(sizeof(buffer), count));
 		channel = simple_strtoul(p, NULL, 0);
 		if (channel)
 			params.channel = channel;
-- 
1.7.10.4
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public•gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

             reply	other threads:[~2013-01-20  9:53 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-20  9:53 Chen Gang [this message]
     [not found] ` <50FBBEB2.2000306-bOixZGp5f+dBDgjK7y7TUQ@public.gmane.org>
2013-01-20 10:43   ` [PATCH] drivers/net/wireless/iwlegacy: adding check length for parameter buf Chen Gang F T

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=50FBBEB2.2000306@asianux.com \
    --to=gang.chen-boixzgp5f+dbdgjk7y7tuq@public$(echo .)gmane.org \
    --cc=linux-wireless-u79uwXL29TY76Z2rM5mHXA@public$(echo .)gmane.org \
    --cc=linville-2XuSBdqkA4R54TAoqtyWWQ@public$(echo .)gmane.org \
    --cc=netdev-u79uwXL29TY76Z2rM5mHXA@public$(echo .)gmane.org \
    --cc=sgruszka-H+wXaHxf7aLQT0dZR+AlfA@public$(echo .)gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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