Reject freq <= 0 in wav_start_capture() early, before it is used to
compute the WAV header fields.

Reported-by: Pavee Hui <[email protected]>
Signed-off-by: Marc-André Lureau <[email protected]>
---
 audio/wavcapture.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/audio/wavcapture.c b/audio/wavcapture.c
index 2dac94617104..67bac380ac7d 100644
--- a/audio/wavcapture.c
+++ b/audio/wavcapture.c
@@ -131,6 +131,12 @@ int wav_start_capture(AudioBackend *state, CaptureState 
*s, const char *path,
         return -1;
     }
 
+    if (freq <= 0 || freq > 384000) {
+        error_report("invalid frequency %d, must be between 1 and 384000",
+                     freq);
+        return -1;
+    }
+
     stereo = nchannels == 2;
     bits16 = bits == 16;
 

-- 
2.56.0.rc0.29.g47ce80527c56


Reply via email to