Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e8988933 authored by Michael Buesch's avatar Michael Buesch Committed by Linus Torvalds
Browse files

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: default avatarMichael Buesch <mb@bu3sch.de>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent c02e3f36
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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)