[linux-dvb] Digitv USB firmware loading issue [PATCH]

Wolfgang Rohdewald wolfgang at rohdewald.de
Fri Dec 9 22:08:19 CET 2005


On Freitag 09 Dezember 2005 19:28, Jon Burgess wrote:
> Jan Kämpe wrote:
> >  int dvb_usb_get_hexline(const struct firmware *fw, struct hexline *hx, int *pos)
> >  {
> > -	u8 *b = (u8 *) &fw->data[*pos];
> >  	int data_offs = 4;
> >  	if (*pos >= fw->size)
> >  		return 0;
> >  
> > +	u8 *b = (u8 *) &fw->data[*pos];
> >  	memset(hx,0,sizeof(struct hexline));
> 
> I don't see why this change is needed and it breaks on older GCC.

if *pos >= fw->size, data[*pos] will access unallocated memory behind data.

int dvb_usb_get_hexline(const struct firmware *fw, struct hexline *hx, int *pos)
{
-	u8 *b = (u8 *) &fw->data[*pos];
+	u8 *b;
 	int data_offs = 4;
 	if (*pos >= fw->size)
 		return 0;
 
+	*b = (u8 *) &fw->data[*pos];
 	memset(hx,0,sizeof(struct hexline));
 

-- 
Wolfgang



More information about the linux-dvb mailing list