audio/wavcapture: prevent freq overflow and corrupted WAV header

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

Reported-by: Hui Peng <benquike@gmail.com>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-ID: <20261004-issue-4560-v1-12-ccbef537cbeb@redhat.com>
This commit is contained in:
Marc-André Lureau committed 2026-10-13 17:22:49 +04:00
1 parent b09d2fdb6a
commit 3fefea5d94
1 file changed
+6
+6
View File
@@ -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;