All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Jaroslav Kysela <perex@perex.cz>
Cc: alsa-devel@alsa-project.org, kernel-janitors@vger.kernel.org,
	Takashi Iwai <tiwai@suse.com>
Subject: [PATCH 2/2] ALSA: control - off by one in store_mode()
Date: Fri, 2 Apr 2021 14:42:50 +0300	[thread overview]
Message-ID: <YGcDOtrimR46vr0k@mwanda> (raw)
In-Reply-To: <YGcDETcdqVUIl1+y@mwanda>

If count is 16 then this will put the NUL terminator one element beyond
the end of the array.

Fixes: cb17fe0045aa ("ALSA: control - add sysfs support to the LED trigger module")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
 sound/core/control_led.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sound/core/control_led.c b/sound/core/control_led.c
index 202b475d0bf3..ab5a455723c8 100644
--- a/sound/core/control_led.c
+++ b/sound/core/control_led.c
@@ -391,7 +391,7 @@ static ssize_t store_mode(struct device *dev, struct device_attribute *attr,
 {
 	struct snd_ctl_led *led = container_of(dev, struct snd_ctl_led, dev);
 	char _buf[16];
-	size_t l = min(count, sizeof(_buf) - 1) + 1;
+	size_t l = min(count, sizeof(_buf) - 1);
 	enum snd_ctl_led_mode mode;
 
 	memcpy(_buf, buf, l);
-- 
2.30.2


WARNING: multiple messages have this Message-ID (diff)
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Jaroslav Kysela <perex@perex.cz>
Cc: Takashi Iwai <tiwai@suse.com>,
	alsa-devel@alsa-project.org, kernel-janitors@vger.kernel.org
Subject: [PATCH 2/2] ALSA: control - off by one in store_mode()
Date: Fri, 2 Apr 2021 14:42:50 +0300	[thread overview]
Message-ID: <YGcDOtrimR46vr0k@mwanda> (raw)
In-Reply-To: <YGcDETcdqVUIl1+y@mwanda>

If count is 16 then this will put the NUL terminator one element beyond
the end of the array.

Fixes: cb17fe0045aa ("ALSA: control - add sysfs support to the LED trigger module")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
 sound/core/control_led.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sound/core/control_led.c b/sound/core/control_led.c
index 202b475d0bf3..ab5a455723c8 100644
--- a/sound/core/control_led.c
+++ b/sound/core/control_led.c
@@ -391,7 +391,7 @@ static ssize_t store_mode(struct device *dev, struct device_attribute *attr,
 {
 	struct snd_ctl_led *led = container_of(dev, struct snd_ctl_led, dev);
 	char _buf[16];
-	size_t l = min(count, sizeof(_buf) - 1) + 1;
+	size_t l = min(count, sizeof(_buf) - 1);
 	enum snd_ctl_led_mode mode;
 
 	memcpy(_buf, buf, l);
-- 
2.30.2


  reply	other threads:[~2021-04-02 11:44 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-02 11:42 [PATCH 1/2] ALSA: control - fix a leak in snd_ctl_led_init() Dan Carpenter
2021-04-02 11:42 ` Dan Carpenter
2021-04-02 11:42 ` Dan Carpenter [this message]
2021-04-02 11:42   ` [PATCH 2/2] ALSA: control - off by one in store_mode() Dan Carpenter
2021-04-02 17:52   ` Jaroslav Kysela
2021-04-02 17:52     ` Jaroslav Kysela
2021-04-06 11:34     ` Takashi Iwai
2021-04-06 11:34       ` Takashi Iwai
2021-04-02 17:57 ` [PATCH 1/2] ALSA: control - fix a leak in snd_ctl_led_init() Jaroslav Kysela
2021-04-02 17:57   ` Jaroslav Kysela
2021-04-09 12:34   ` [PATCH 1/2 v2] ALSA: control - double free " Dan Carpenter
2021-04-09 12:34     ` Dan Carpenter
2021-04-09 13:12     ` Jaroslav Kysela
2021-04-09 13:12       ` Jaroslav Kysela
2021-04-09 14:16     ` Takashi Iwai
2021-04-09 14:16       ` Takashi Iwai

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=YGcDOtrimR46vr0k@mwanda \
    --to=dan.carpenter@oracle.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=perex@perex.cz \
    --cc=tiwai@suse.com \
    /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.