Skip to contentSkip to conversation

ivtv: Read buffer overflow

PATCH In review Roel Kluin 2 participants 2 messages Jul 23, 2009 – Jul 24, 2009 Media (V4L/DVB)

lore
Share & tools
lore

Roel Kluin

author
#0 lore raw

PATCH 1/1 ivtv: Read buffer overflow

This mistakenly tests against sizeof(freqs) instead of the array size. Due to the mask the only illegal value possible was 3.

---

drivers/media/video/ivtv/ivtv-controls.c +2 -1
index a3b77ed..4a9c8ce 100644
@@ -17,6 +17,7 @@
     along with this program; if not, write to the Free Software
     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
+#include <linux/kernel.h>
 
 #include "ivtv-driver.h"
 #include "ivtv-cards.h"
@@ -281,7 +282,7 @@ int ivtv_s_ext_ctrls(struct file *file, void *fh, struct v4l2_ext_controls *c)
 		idx = p.audio_properties & 0x03;
 		/* The audio clock of the digitizer must match the codec sample
 		   rate otherwise you get some very strange effects. */
-		if (idx < sizeof(freqs))
+		if (idx < ARRAY_SIZE(freqs))
 			ivtv_call_all(itv, audio, s_clock_freq, freqs[idx]);
 		return err;
 	}
Acked-by on v1 1/1
#1 lore raw
Quoted 4 lines · Roel Kluin

This mistakenly tests against sizeof(freqs) instead of the array size. Due to the mask the only illegal value possible was 3.

The cx18 driver suffers from the exact same defect in cx18-controls.c.

Quoted 27 lines

---

drivers/media/video/ivtv/ivtv-controls.c +2 -2
index a3b77ed..4a9c8ce 100644
@@ -17,6 +17,7 @@
     along with this program; if not, write to the Free Software
     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
+#include <linux/kernel.h>
 
 #include "ivtv-driver.h"
 #include "ivtv-cards.h"
@@ -281,7 +282,7 @@ int ivtv_s_ext_ctrls(struct file *file, void *fh, struct v4l2_ext_controls *c)
 		idx = p.audio_properties & 0x03;
 		/* The audio clock of the digitizer must match the codec sample
 		   rate otherwise you get some very strange effects. */
-		if (idx < sizeof(freqs))
+		if (idx < ARRAY_SIZE(freqs))
 			ivtv_call_all(itv, audio, s_clock_freq, freqs[idx]);
 		return err;
 	}
--

To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html