All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Laight <David.Laight@ACULAB.COM>
To: 'Chen-Yu Tsai' <wens@csie.org>,
	Johannes Berg <johannes@sipsolutions.net>,
	"David S. Miller" <davem@davemloft.net>
Cc: "netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-arm-kernel@lists.infradead.org"
	<linux-arm-kernel@lists.infradead.org>,
	"linux-sunxi@googlegroups.com" <linux-sunxi@googlegroups.com>,
	Maxime Ripard <maxime.ripard@free-electrons.com>,
	"linux-wireless@vger.kernel.org" <linux-wireless@vger.kernel.org>
Subject: RE: [PATCH RFC 1/6] net: rfkill: gpio: fix gpio name buffer size off by 1
Date: Fri, 17 Jan 2014 09:46:08 +0000	[thread overview]
Message-ID: <063D6719AE5E284EB5DD2968C1650D6D45EA9D@AcuExch.aculab.com> (raw)
In-Reply-To: <1389941251-32692-2-git-send-email-wens@csie.org>

From: Chen-Yu Tsai
> snprintf should be passed the complete size of the buffer, including
> the space for '\0'. The previous code resulted in the *_reset and
> *_shutdown strings being truncated.
...
> diff --git a/net/rfkill/rfkill-gpio.c b/net/rfkill/rfkill-gpio.c
...
> -	snprintf(rfkill->reset_name, len + 6 , "%s_reset", rfkill->name);
> -	snprintf(rfkill->shutdown_name, len + 9, "%s_shutdown", rfkill->name);
> +	snprintf(rfkill->reset_name, len + 7 , "%s_reset", rfkill->name);
> +	snprintf(rfkill->shutdown_name, len + 10, "%s_shutdown", rfkill->name);

I can't find the context for the above, but they look very dubious.
I'd expect: snprintf(foo, sizeof foo, ...).
If you are trying to truncate rfkill->name you need to use %.*s.

	David




WARNING: multiple messages have this Message-ID (diff)
From: David.Laight@ACULAB.COM (David Laight)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH RFC 1/6] net: rfkill: gpio: fix gpio name buffer size off by 1
Date: Fri, 17 Jan 2014 09:46:08 +0000	[thread overview]
Message-ID: <063D6719AE5E284EB5DD2968C1650D6D45EA9D@AcuExch.aculab.com> (raw)
In-Reply-To: <1389941251-32692-2-git-send-email-wens@csie.org>

From: Chen-Yu Tsai
> snprintf should be passed the complete size of the buffer, including
> the space for '\0'. The previous code resulted in the *_reset and
> *_shutdown strings being truncated.
...
> diff --git a/net/rfkill/rfkill-gpio.c b/net/rfkill/rfkill-gpio.c
...
> -	snprintf(rfkill->reset_name, len + 6 , "%s_reset", rfkill->name);
> -	snprintf(rfkill->shutdown_name, len + 9, "%s_shutdown", rfkill->name);
> +	snprintf(rfkill->reset_name, len + 7 , "%s_reset", rfkill->name);
> +	snprintf(rfkill->shutdown_name, len + 10, "%s_shutdown", rfkill->name);

I can't find the context for the above, but they look very dubious.
I'd expect: snprintf(foo, sizeof foo, ...).
If you are trying to truncate rfkill->name you need to use %.*s.

	David

  reply	other threads:[~2014-01-17  9:48 UTC|newest]

Thread overview: 89+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-17  6:47 [PATCH RFC 0/6] net: rfkill: gpio: Add device tree support Chen-Yu Tsai
2014-01-17  6:47 ` Chen-Yu Tsai
2014-01-17  6:47 ` Chen-Yu Tsai
2014-01-17  6:47 ` [PATCH RFC 1/6] net: rfkill: gpio: fix gpio name buffer size off by 1 Chen-Yu Tsai
2014-01-17  6:47   ` Chen-Yu Tsai
2014-01-17  6:47   ` Chen-Yu Tsai
2014-01-17  9:46   ` David Laight [this message]
2014-01-17  9:46     ` David Laight
2014-01-17  9:46     ` David Laight
2014-01-17  9:59     ` Chen-Yu Tsai
2014-01-17  9:59       ` Chen-Yu Tsai
2014-01-17  9:59       ` Chen-Yu Tsai
2014-01-17  9:59       ` Chen-Yu Tsai
2014-01-17  6:47 ` [PATCH RFC 2/6] net: rfkill: gpio: use clk_prepare_enable/clk_disable_unprepare Chen-Yu Tsai
2014-01-17  6:47   ` Chen-Yu Tsai
2014-01-17  6:47   ` Chen-Yu Tsai
2014-01-17  6:47 ` [PATCH RFC 3/6] net: rfkill: gpio: fix reversed clock enable state Chen-Yu Tsai
2014-01-17  6:47   ` Chen-Yu Tsai
2014-01-17  6:47   ` Chen-Yu Tsai
2014-01-17  6:47 ` [PATCH RFC 4/6] net: rfkill: gpio: add device tree support Chen-Yu Tsai
2014-01-17  6:47   ` Chen-Yu Tsai
2014-01-17  6:47   ` Chen-Yu Tsai
2014-01-17 16:47   ` Arnd Bergmann
2014-01-17 16:47     ` Arnd Bergmann
2014-01-17 16:47     ` Arnd Bergmann
2014-01-17 17:43     ` Chen-Yu Tsai
2014-01-17 17:43       ` Chen-Yu Tsai
2014-01-17 17:43       ` Chen-Yu Tsai
2014-01-17 20:13       ` Arnd Bergmann
2014-01-17 20:13         ` Arnd Bergmann
2014-01-17 20:13         ` Arnd Bergmann
2014-01-17 23:11       ` Linus Walleij
2014-01-17 23:11         ` Linus Walleij
2014-01-17 23:11         ` Linus Walleij
2014-01-18  4:41         ` Chen-Yu Tsai
2014-01-18  4:41           ` Chen-Yu Tsai
2014-01-18  4:41           ` Chen-Yu Tsai
2014-01-20  8:10         ` Heikki Krogerus
2014-01-20  8:10           ` Heikki Krogerus
2014-01-20  8:10           ` Heikki Krogerus
2014-01-21  3:11         ` Alexandre Courbot
2014-01-21  3:11           ` Alexandre Courbot
2014-01-21  9:35           ` Linus Walleij
2014-01-21  9:35             ` Linus Walleij
2014-01-21  9:35             ` Linus Walleij
2014-01-21 12:35             ` Arnd Bergmann
2014-01-21 12:35               ` Arnd Bergmann
2014-01-21 12:35               ` Arnd Bergmann
2014-01-21 14:53               ` Alexandre Courbot
2014-01-21 14:53                 ` Alexandre Courbot
2014-01-21 14:53                 ` Alexandre Courbot
2014-01-21 14:53                 ` Alexandre Courbot
2014-01-21 15:25                 ` Mika Westerberg
2014-01-21 15:25                   ` Mika Westerberg
2014-01-21 15:25                   ` Mika Westerberg
2014-01-21 18:50                 ` Arnd Bergmann
2014-01-21 18:50                   ` Arnd Bergmann
2014-01-21 18:50                   ` Arnd Bergmann
2014-01-21 18:50                   ` Arnd Bergmann
2014-01-22 12:38                   ` Mark Brown
2014-01-22 12:38                     ` Mark Brown
2014-01-22 12:38                     ` Mark Brown
2014-01-22 12:38                     ` Mark Brown
2014-01-22  9:54                 ` Linus Walleij
2014-01-22  9:54                   ` Linus Walleij
2014-01-22  9:54                   ` Linus Walleij
2014-01-22  9:54                   ` Linus Walleij
2014-01-22  9:58                 ` Linus Walleij
2014-01-22  9:58                   ` Linus Walleij
2014-01-22  9:58                   ` Linus Walleij
2014-01-22  9:58                   ` Linus Walleij
2014-01-22 11:00                   ` Mika Westerberg
2014-01-22 11:00                     ` Mika Westerberg
2014-01-22 11:00                     ` Mika Westerberg
2014-01-22 11:00                     ` Mika Westerberg
2014-01-27 14:24   ` Maxime Ripard
2014-01-27 14:24     ` Maxime Ripard
2014-01-27 14:24     ` Maxime Ripard
2014-01-29  4:01     ` [linux-sunxi] " Chen-Yu Tsai
2014-01-29  4:01       ` Chen-Yu Tsai
2014-01-29  4:01       ` Chen-Yu Tsai
2014-01-17  6:47 ` [PATCH RFC 5/6] net: rfkill: gpio: add clock-frequency device tree property Chen-Yu Tsai
2014-01-17  6:47   ` Chen-Yu Tsai
2014-01-17  6:47   ` Chen-Yu Tsai
2014-01-17  6:47 ` [PATCH RFC 6/6] ARM: sun7i: cubietruck: enable bluetooth module Chen-Yu Tsai
2014-01-17  6:47   ` Chen-Yu Tsai
2014-01-17  6:47   ` Chen-Yu Tsai
2014-01-17 20:26 ` [PATCH RFC 0/6] net: rfkill: gpio: Add device tree support Johannes Berg
2014-01-17 20:26   ` Johannes Berg

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=063D6719AE5E284EB5DD2968C1650D6D45EA9D@AcuExch.aculab.com \
    --to=david.laight@aculab.com \
    --cc=davem@davemloft.net \
    --cc=devicetree@vger.kernel.org \
    --cc=johannes@sipsolutions.net \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sunxi@googlegroups.com \
    --cc=linux-wireless@vger.kernel.org \
    --cc=maxime.ripard@free-electrons.com \
    --cc=netdev@vger.kernel.org \
    --cc=wens@csie.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.