Bug#635906: Patch for Division by zero in ov_read_filter

Daniel Exner <[email protected]> Mon, 18 Jun 2012 22:18:29 +0200
Newsgroups gmane.linux.debian.devel.bugs.general,gmane.comp.multimedia.ogg.vorbis.general
Message-ID <[email protected]>
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Hi,

I ran into a SIPFPE from libvorbisfile while trying to run FoFiX.
I traced it down to a missing null check.
See attached patch for a fix, that should also fix the bug in Debian BTS.
Thanks!

Greetings
Daniel Exner
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iF4EAREIAAYFAk/fjQUACgkQIL9GFNSEFHzcJQD+Munhex1zXax324KwIQDFY6Pn
pA50KkvHswbb7Bl96AgA/2PCYKJAQI6Ps0CH9rfaBRej9X/QNzDNxgUUX+AtVNZ+
=VnfE
-----END PGP SIGNATURE-----
ov_read_filter.patch (text/plain, 500 B)
--- libvorbis-1.3.3/lib/vorbisfile.c	2010-10-27 16:54:00.000000000 +0200
+++ libvorbis-1.3.3.new/lib/vorbisfile.c	2012-06-18 22:05:48.000000000 +0200
@@ -1902,7 +1902,8 @@
     long channels=ov_info(vf,-1)->channels;
     long bytespersample=word * channels;
     vorbis_fpu_control fpu;
-    if(samples>length/bytespersample)samples=length/bytespersample;
+    if(bytespersample && samples>length/bytespersample)
+     samples=length/bytespersample;
 
     if(samples <= 0)
       return OV_EINVAL;
ov_read_filter.patch.sig (application/octet-stream, 96 B) - not displayed