qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 9/9] audio: audio_generic_get_buffer_in should honor *size


From: Volker Rümelin
Subject: [PATCH 9/9] audio: audio_generic_get_buffer_in should honor *size
Date: Thu, 23 Jan 2020 08:49:43 +0100

The function generic_get_buffer_in currently ignores the *size
parameter and may return a buffer larger than *size.

As a result the variable samples in function
audio_pcm_hw_run_in may underflow. The while loop then most
likely will never termiate.

This bug was reported at http://bugs.debian.org/948658.

Signed-off-by: Volker Rümelin <address@hidden>
---
 audio/audio.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/audio/audio.c b/audio/audio.c
index 81822bfec9..f5fb6cbf53 100644
--- a/audio/audio.c
+++ b/audio/audio.c
@@ -1406,7 +1406,8 @@ void *audio_generic_get_buffer_in(HWVoiceIn *hw, size_t 
*size)
     }
     assert(start >= 0 && start < hw->size_emul);
 
-    *size = MIN(hw->pending_emul, hw->size_emul - start);
+    *size = MIN(*size, hw->pending_emul);
+    *size = MIN(*size, hw->size_emul - start);
     return hw->buf_emul + start;
 }
 
-- 
2.16.4




reply via email to

[Prev in Thread] Current Thread [Next in Thread]