bpo-32056: Improve exceptions in aifc, wave and sunau. (GH-5951)

(cherry picked from commit 134cb01cda50f02725575808130b05d2d776693f)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
diff --git a/Lib/aifc.py b/Lib/aifc.py
index 3d2dc56..1916e7e 100644
--- a/Lib/aifc.py
+++ b/Lib/aifc.py
@@ -467,6 +467,10 @@
         self._nframes = _read_long(chunk)
         self._sampwidth = (_read_short(chunk) + 7) // 8
         self._framerate = int(_read_float(chunk))
+        if self._sampwidth <= 0:
+            raise Error('bad sample width')
+        if self._nchannels <= 0:
+            raise Error('bad # of channels')
         self._framesize = self._nchannels * self._sampwidth
         if self._aifc:
             #DEBUG: SGI's soundeditor produces a bad size :-(