Skip to content

Commit e898893

Browse files
Michael Bueschtorvalds
authored andcommitted
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>
1 parent c02e3f3 commit e898893

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

‎drivers/block/DAC960.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6562,7 +6562,7 @@ static int DAC960_ProcWriteUserCommand(struct file *file,
65626562
if (copy_from_user(CommandBuffer, Buffer, Count)) return -EFAULT;
65636563
CommandBuffer[Count] = '\0';
65646564
Length = strlen(CommandBuffer);
6565-
if (CommandBuffer[Length-1] == '\n')
6565+
if (Length > 0 && CommandBuffer[Length-1] == '\n')
65666566
CommandBuffer[--Length] = '\0';
65676567
if (Controller->FirmwareType == DAC960_V1_Controller)
65686568
return (DAC960_V1_ExecuteUserCommand(Controller, CommandBuffer)

0 commit comments

Comments
 (0)