Re: [AD] Memory overrun in load_wav

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


> > It shouldn't read in "length" bytes. It should read "len*bits/8" bytes.
>
> Can someone provide a patch for this?  Thanks.

Well, it has to read in "length" bytes since that is the amount of data in
the WAV chunk, so if we modified the fread loop it'd have to do an extra
fgetc if there was an odd byte left over. Therefore, I think Vincent's patch
is the easiest solution.

I've attached a diff for it, not sure whether this can be applied against
CVS directly or not.

Cheers
Chris
--- sound_old.c	Wed Jul 27 23:54:42 2005
+++ sound.c	Sat Nov 26 14:15:14 2005
@@ -1010,7 +1010,7 @@
 	    goto getout;
       }
       else if (memcmp(buffer, "data", 4) == 0) {
-	 len = length / channels;
+	 len = (length + channels - 1) / channels;
 
 	 if (bits == 16)
 	    len /= 2;


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/