Blame SOURCES/kvm-audio-audio_generic_get_buffer_in-should-honor-size.patch

1072c8
From 96c8fcafa7325cd0e8a23a743a55f0ad0aa9f79b Mon Sep 17 00:00:00 2001
1072c8
From: Gerd Hoffmann <kraxel@redhat.com>
1072c8
Date: Thu, 18 Mar 2021 09:13:42 -0400
1072c8
Subject: [PATCH 5/5] audio: audio_generic_get_buffer_in should honor *size
1072c8
MIME-Version: 1.0
1072c8
Content-Type: text/plain; charset=UTF-8
1072c8
Content-Transfer-Encoding: 8bit
1072c8
1072c8
RH-Author: Gerd Hoffmann <kraxel@redhat.com>
1072c8
Message-id: <20210318091342.3232471-2-kraxel@redhat.com>
1072c8
Patchwork-id: 101352
1072c8
O-Subject: [RHEL-8.4.0 qemu-kvm PATCH 1/1] audio: audio_generic_get_buffer_in should honor *size
1072c8
Bugzilla: 1932823
1072c8
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
1072c8
RH-Acked-by: Danilo de Paula <ddepaula@redhat.com>
1072c8
RH-Acked-by: Philippe Mathieu-Daudé <philmd@redhat.com>
1072c8
1072c8
From: Volker Rümelin <vr_qemu@t-online.de>
1072c8
1072c8
The function generic_get_buffer_in currently ignores the *size
1072c8
parameter and may return a buffer larger than *size.
1072c8
1072c8
As a result the variable samples in function
1072c8
audio_pcm_hw_run_in may underflow. The while loop then most
1072c8
likely will never termiate.
1072c8
1072c8
Buglink: http://bugs.debian.org/948658
1072c8
Signed-off-by: Volker Rümelin <vr_qemu@t-online.de>
1072c8
Message-Id: <20200123074943.6699-9-vr_qemu@t-online.de>
1072c8
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
1072c8
(cherry picked from commit 599eac4e5a41e828645594097daee39373acc3c0)
1072c8
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
1072c8
---
1072c8
 audio/audio.c | 3 ++-
1072c8
 1 file changed, 2 insertions(+), 1 deletion(-)
1072c8
1072c8
diff --git a/audio/audio.c b/audio/audio.c
1072c8
index 56fae55047..39a62fc62a 100644
1072c8
--- a/audio/audio.c
1072c8
+++ b/audio/audio.c
1072c8
@@ -1402,7 +1402,8 @@ void *audio_generic_get_buffer_in(HWVoiceIn *hw, size_t *size)
1072c8
     }
1072c8
     assert(start >= 0 && start < hw->size_emul);
1072c8
 
1072c8
-    *size = MIN(hw->pending_emul, hw->size_emul - start);
1072c8
+    *size = MIN(*size, hw->pending_emul);
1072c8
+    *size = MIN(*size, hw->size_emul - start);
1072c8
     return hw->buf_emul + start;
1072c8
 }
1072c8
 
1072c8
-- 
1072c8
2.27.0
1072c8