https://marc.info/?l=oss-security&m=167571683504082&w=2

unbreak wav gsm
see:
https://marc.info/?l=oss-security&m=167882517702862&w=2
https://marc.info/?l=oss-security&m=168026419507884&w=2

Index: src/wav.c
--- src/wav.c.orig
+++ src/wav.c
@@ -654,6 +654,15 @@ static int wav_read_fmt(sox_format_t *ft, uint32_t len
     if (err)
         return SOX_EOF;
 
+    if (wav->bitsPerSample == 0
+#ifdef HAVE_LIBGSM
+            && wav->formatTag != WAVE_FORMAT_GSM610
+#endif
+    ){
+        lsx_fail_errno(ft, SOX_EHDR, "WAV file bits per sample is zero");
+        return SOX_EOF;
+    }
+
     /* non-PCM formats except alaw and mulaw formats have extended fmt chunk.
      * Check for those cases.
      */
@@ -963,7 +972,11 @@ static int startread(sox_format_t *ft)
 #endif
     }
 
-    if (!wav->numSamples)
+    if (!wav->numSamples
+#ifdef HAVE_LIBGSM
+            && wav->formatTag != WAVE_FORMAT_GSM610
+#endif
+    )
         wav->numSamples = div_bits(qwDataLength, ft->encoding.bits_per_sample)
             / ft->signal.channels;
 
@@ -1348,8 +1361,10 @@ static int wavwritehdr(sox_format_t * ft, int second_h
         (dwSamplesWritten + wSamplesPerBlock - 1) / wSamplesPerBlock;
     dwDataLength = blocksWritten * wBlockAlign;
 
+#ifdef HAVE_LIBGSM
     if (wFormatTag == WAVE_FORMAT_GSM610)
         dwDataLength = (dwDataLength+1) & ~1u; /* round up to even */
+#endif
 
     if (wFormatTag == WAVE_FORMAT_PCM && (wBitsPerSample > 16 || wChannels > 2)
         && strcmp(ft->filetype, "wavpcm")) {
@@ -1444,9 +1459,11 @@ static int wavwritehdr(sox_format_t * ft, int second_h
             lsx_writew(ft, (uint16_t)(lsx_ms_adpcm_i_coef[i][1]));
         }
         break;
+#ifdef HAVE_LIBGSM
         case WAVE_FORMAT_GSM610:
         lsx_writew(ft, wSamplesPerBlock);
         break;
+#endif
         default:
         break;
     }
@@ -1554,7 +1571,9 @@ static int stopwrite(sox_format_t * ft)
 
         /* Add a pad byte if the number of data bytes is odd.
            See wavwritehdr() above for the calculation. */
+#ifdef HAVE_LIBGSM
         if (wav->formatTag != WAVE_FORMAT_GSM610)
+#endif
           lsx_padbytes(ft, (size_t)((wav->numSamples + wav->samplesPerBlock - 1)/wav->samplesPerBlock*wav->blockAlign) % 2);
 
         free(wav->packet);
@@ -1594,6 +1613,7 @@ static int seek(sox_format_t * ft, uint64_t offset)
 
   if (ft->encoding.bits_per_sample & 7)
     lsx_fail_errno(ft, SOX_ENOTSUP, "seeking not supported with this encoding");
+#ifdef HAVE_LIBGSM
   else if (wav->formatTag == WAVE_FORMAT_GSM610) {
     int alignment;
     size_t gsmoff;
@@ -1613,7 +1633,9 @@ static int seek(sox_format_t * ft, uint64_t offset)
           new_offset += (wav->samplesPerBlock - alignment);
       wav->numSamples = ft->signal.length - (new_offset / ft->signal.channels);
     }
-  } else {
+  }
+#endif /* HAVE_LIBGSM */
+  else {
     double wide_sample = offset - (offset % ft->signal.channels);
     double to_d = wide_sample * ft->encoding.bits_per_sample / 8;
     off_t to = to_d;
