From: Helmut Grohne <helmut@subdivi.de>
Subject: wav: reject 0 bits per sample to avoid division by zero
Bug: https://sourceforge.net/p/sox/bugs/349/
Bug-Debian: https://bugs.debian.org/1021135

--- a/src/wav.c
+++ b/src/wav.c
@@ -506,7 +506,7 @@
     unsigned short wChannels;       /* number of channels */
     uint32_t      dwSamplesPerSecond; /* samples per second per channel */
     uint32_t      dwAvgBytesPerSec;/* estimate of bytes per second needed */
-    uint16_t wBitsPerSample;  /* bits per sample */
+    uint16_t wBitsPerSample = 0;  /* bits per sample */
     uint32_t wFmtSize;
     uint16_t wExtSize = 0;    /* extended field for non-PCM */
 
@@ -587,6 +587,11 @@
     lsx_readdw(ft, &dwAvgBytesPerSec);   /* Average bytes/second */
     lsx_readw(ft, &(wav->blockAlign));   /* Block align */
     lsx_readw(ft, &wBitsPerSample);      /* bits per sample per channel */
+    if (wBitsPerSample == 0)
+    {
+        lsx_fail_errno(ft, SOX_EHDR, "WAV file bits per sample is zero");
+        return SOX_EOF;
+    }
     len -= 16;
 
     if (wav->formatTag == WAVE_FORMAT_EXTENSIBLE)
