shithub: aubio

Download patch

ref: 25ecb7338cebc5b8c79092347839c78349ec33f1
parent: 560fc509c8f140a342daba01e1826cbef579fe1f
author: Paul Brossier <piem@piem.org>
date: Tue Feb 6 17:32:59 EST 2018

src/io/source_wavread.c: add some input validation (closes: #158)

--- a/src/io/source_wavread.c
+++ b/src/io/source_wavread.c
@@ -189,6 +189,26 @@
   // BitsPerSample
   bytes_read += fread(buf, 1, 2, s->fid);
   bitspersample = read_little_endian(buf, 2);
+
+  if ( channels == 0 ) {
+    AUBIO_ERR("source_wavread: Failed opening %s (number of channels can not be 0)\n", s->path);
+    goto beach;
+  }
+
+  if ( sr == 0 ) {
+    AUBIO_ERR("source_wavread: Failed opening %s (samplerate can not be 0)\n", s->path);
+    goto beach;
+  }
+
+  if ( byterate == 0 ) {
+    AUBIO_ERR("source_wavread: Failed opening %s (byterate can not be 0)\n", s->path);
+    goto beach;
+  }
+
+  if ( bitspersample == 0 ) {
+    AUBIO_ERR("source_wavread: Failed opening %s (bitspersample can not be 0)\n", s->path);
+    goto beach;
+  }
 #if 0
   if ( bitspersample != 16 ) {
     AUBIO_ERR("source_wavread: can not process %dbit file %s\n",