Skip to contentSkip to conversation

oss/sb_audio: prevent divide by zero bug

PATCH Applied Dan Carpenter 2 participants 2 messages Aug 18, 2012 – Aug 20, 2012

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 oss/sb_audio: prevent divide by zero bug

Speed comes from get_user() in audio_ioctl(). We use it to set the "s" variable before clamping it to valid values so it could lead to a divide by zero bug.

sound/oss/sb_audio.c +3 -1
index 733b014..b2b3c01 100644
@@ -575,13 +575,15 @@ static int jazz16_audio_set_speed(int dev, int speed)
 	if (speed > 0)
 	{
 		int tmp;
-		int s = speed * devc->channels;
+		int s;
 
 		if (speed < 5000)
 			speed = 5000;
 		if (speed > 44100)
 			speed = 44100;
 
+		s = speed * devc->channels;
+
 		devc->tconst = (256 - ((1000000 + s / 2) / s)) & 0xff;
 
 		tmp = 256 - devc->tconst;
Applied
#1 lore raw

At Sat, 18 Aug 2012 18:55:15 +0300,

Quoted 6 lines · Dan Carpenter

Speed comes from get_user() in audio_ioctl(). We use it to set the "s" variable before clamping it to valid values so it could lead to a divide by zero bug.

Thanks, applied now.

Takashi

Quoted 22 lines
sound/oss/sb_audio.c +3 -1
index 733b014..b2b3c01 100644
@@ -575,13 +575,15 @@ static int jazz16_audio_set_speed(int dev, int speed)
 	if (speed > 0)
 	{
 		int tmp;
-		int s = speed * devc->channels;
+		int s;
 
 		if (speed < 5000)
 			speed = 5000;
 		if (speed > 44100)
 			speed = 44100;
 
+		s = speed * devc->channels;
+
 		devc->tconst = (256 - ((1000000 + s / 2) / s)) & 0xff;
 
 		tmp = 256 - devc->tconst;