mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-11-01 17:08:10 +00:00
dac960: fix undefined behavior on empty string
Fix undefined behavior due to a buffer underrun if an empty string is written to the proc file. Signed-off-by: Michael Buesch <mb@bu3sch.de> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
c02e3f361c
commit
e898893399
1 changed files with 1 additions and 1 deletions
|
@ -6562,7 +6562,7 @@ static int DAC960_ProcWriteUserCommand(struct file *file,
|
|||
if (copy_from_user(CommandBuffer, Buffer, Count)) return -EFAULT;
|
||||
CommandBuffer[Count] = '\0';
|
||||
Length = strlen(CommandBuffer);
|
||||
if (CommandBuffer[Length-1] == '\n')
|
||||
if (Length > 0 && CommandBuffer[Length-1] == '\n')
|
||||
CommandBuffer[--Length] = '\0';
|
||||
if (Controller->FirmwareType == DAC960_V1_Controller)
|
||||
return (DAC960_V1_ExecuteUserCommand(Controller, CommandBuffer)
|
||||
|
|
Loading…
Reference in a new issue