mirror of
https://github.com/Motorhead1991/qemu.git
synced 2026-02-11 19:39:26 -07:00
es1370: check total frame count against current frame
A guest user may set channel frame count via es1370_write()
such that, in es1370_transfer_audio(), total frame count
'size' is lesser than the number of frames that are processed
'cnt'.
int cnt = d->frame_cnt >> 16;
int size = d->frame_cnt & 0xffff;
if (size < cnt), it results in incorrect calculations leading
to OOB access issue(s). Add check to avoid it.
Reported-by: Ren Ding <rding@gatech.edu>
Reported-by: Hanqing Zhao <hanqing@gatech.edu>
Signed-off-by: Prasad J Pandit <pjp@fedoraproject.org>
Message-id: 20200514200608.1744203-1-ppandit@redhat.com
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
This commit is contained in:
parent
fea8f3ed73
commit
369ff955a8
1 changed files with 5 additions and 2 deletions
|
|
@ -643,6 +643,9 @@ static void es1370_transfer_audio (ES1370State *s, struct chan *d, int loop_sel,
|
|||
int csc_bytes = (csc + 1) << d->shift;
|
||||
int cnt = d->frame_cnt >> 16;
|
||||
int size = d->frame_cnt & 0xffff;
|
||||
if (size < cnt) {
|
||||
return;
|
||||
}
|
||||
int left = ((size - cnt + 1) << 2) + d->leftover;
|
||||
int transferred = 0;
|
||||
int temp = MIN (max, MIN (left, csc_bytes));
|
||||
|
|
@ -651,7 +654,7 @@ static void es1370_transfer_audio (ES1370State *s, struct chan *d, int loop_sel,
|
|||
addr += (cnt << 2) + d->leftover;
|
||||
|
||||
if (index == ADC_CHANNEL) {
|
||||
while (temp) {
|
||||
while (temp > 0) {
|
||||
int acquired, to_copy;
|
||||
|
||||
to_copy = MIN ((size_t) temp, sizeof (tmpbuf));
|
||||
|
|
@ -669,7 +672,7 @@ static void es1370_transfer_audio (ES1370State *s, struct chan *d, int loop_sel,
|
|||
else {
|
||||
SWVoiceOut *voice = s->dac_voice[index];
|
||||
|
||||
while (temp) {
|
||||
while (temp > 0) {
|
||||
int copied, to_copy;
|
||||
|
||||
to_copy = MIN ((size_t) temp, sizeof (tmpbuf));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue