ALSA: control: Trim whitespace from sysfs input
PATCH 1/1 ALSA: control: Trim whitespace from sysfs input
The attach and detach sysfs interfaces receive input from userspace.
When userspace writes a value using echo, the input normally ends with a newline character.
The parser does not remove this newline in all input formats. For example, a bare numeric ID can be treated as a control name, and an unquoted name= field can include the newline.
Trim leading and trailing whitespace before parsing the input.
This keeps spaces inside mixer control names unchanged.
--- sound/core/control_led.c | 5 +++++ 1 file changed, 5 insertions(+)
sound/core/control_led.c +5 -0
@@ -518,6 +518,11 @@ static ssize_t set_led_id(struct snd_ctl_led_card *led_card, const char *buf, siif (strscpy (buf2, buf,sizeof (buf2)) <0 )return -E2BIG ; + + s =strim (buf2); +if (s != buf2) +memmove (buf2, s,strlen (s) +1 ); +memset (&id,0 ,sizeof (id)); id.iface =SNDRV_CTL_ELEM_IFACE_MIXER ; s = buf2;
Signature · 1 line
2.55.0
[email protected]
AI reviewThank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [Low] ALSA: control: missing Fixes trailer for set_led_id() whitespace fix --
Thank you for your contribution! Sashiko AI review found 1 potential issue to consider:
- [Low] ALSA: control: missing Fixes trailer for set_led_id() whitespace fix
--
commit fba9994b6098b77ca57c53a57ff6876210ceae6a
Author: Sreeraj S Kurup <[email protected]>
Quoted 12 lines
ALSA: control: Trim whitespace from sysfs input
The attach and detach sysfs interfaces receive input from userspace.
When userspace writes a value using echo, the input normally ends with a newline character.
The parser does not remove this newline in all input formats. For example, a bare numeric ID can be treated as a control name, and an unquoted name= field can include the newline.
Quoted 5 lines
Trim leading and trailing whitespace before parsing the input.
This keeps spaces inside mixer control names unchanged.
Signed-off-by Sreeraj S Kurup <[email protected]>
[Severity: Low]
Since this fixes newline handling in set_led_id(), should it include:
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
PATCH v2 1/1 ALSA: control: Trim whitespace from sysfs input
In reply to Sreeraj S KurupThe attach and detach sysfs interfaces receive input from userspace.
When userspace writes a value using echo, the input normally ends with a newline character.
The parser does not remove this newline in all input formats. For example, a bare numeric ID can be treated as a control name, and an unquoted name= field can include the newline.
Trim leading and trailing whitespace before parsing the input.
This keeps spaces inside mixer control names unchanged.
---
v2:
- Add the Fixes trailer.
sound/core/control_led.c | 5 +++++ 1 file changed, 5 insertions(+)
sound/core/control_led.c +5 -0
@@ -518,6 +518,11 @@ static ssize_t set_led_id(struct snd_ctl_led_card *led_card, const char *buf, siif (strscpy (buf2, buf,sizeof (buf2)) <0 )return -E2BIG ; + + s =strim (buf2); +if (s != buf2) +memmove (buf2, s,strlen (s) +1 ); +memset (&id,0 ,sizeof (id)); id.iface =SNDRV_CTL_ELEM_IFACE_MIXER ; s = buf2;
Signature · 1 line
2.55.0
Takashi Iwai
AppliedQuoted 11 lines · Sreeraj S Kurup
The attach and detach sysfs interfaces receive input from userspace.
When userspace writes a value using echo, the input normally ends with a newline character.
The parser does not remove this newline in all input formats. For example, a bare numeric ID can be treated as a control name, and an unquoted name= field can include the newline.
Quoted 6 lines
Trim leading and trailing whitespace before parsing the input.
This keeps spaces inside mixer control names unchanged.
Fixes a135dfb5de15 ("ALSA: led control - add sysfs kcontrol LED marking layer")Signed-off-by Sreeraj S Kurup <[email protected]>
Applied to for-next branch. Thanks.
Takashi
Thanks for applying the patch!
Best regards,
Sreeraj
Hi,
Thanks for applying the patch!
Best regards,
Sreeraj