summaryrefslogtreecommitdiffstats
path: root/drivers/block/DAC960.c
diff options
context:
space:
mode:
authorMichael Buesch <mb@bu3sch.de>2009-09-23 01:43:36 +0200
committerLinus Torvalds <torvalds@linux-foundation.org>2009-09-23 16:39:28 +0200
commite898893399335514b10dfbd75598f8308976abe4 (patch)
treeaf829247f12aed6e9371dcee8ed119ce54a3e0c3 /drivers/block/DAC960.c
parentkmod: fix race in usermodehelper code (diff)
downloadlinux-e898893399335514b10dfbd75598f8308976abe4.tar.xz
linux-e898893399335514b10dfbd75598f8308976abe4.zip
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>
Diffstat (limited to 'drivers/block/DAC960.c')
-rw-r--r--drivers/block/DAC960.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/block/DAC960.c b/drivers/block/DAC960.c
index c77b6f3c28ea..6fa7b0fdbdfd 100644
--- a/drivers/block/DAC960.c
+++ b/drivers/block/DAC960.c
@@ -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)