msacm32: Handle invalid source length in acmStreamPrepareHeader.

Signed-off-by: Bruno Jesus <00cpxxx@gmail.com>
Signed-off-by: Andrew Eikum <aeikum@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Bruno Jesus 2016-08-28 04:07:29 -03:00 committed by Alexandre Julliard
parent 61eda97fd5
commit d4fd43c971
2 changed files with 13 additions and 4 deletions

View File

@ -312,6 +312,11 @@ MMRESULT WINAPI acmStreamPrepareHeader(HACMSTREAM has, PACMSTREAMHEADER pash,
WARN("invalid use of reserved parameter\n");
return MMSYSERR_INVALFLAG;
}
if (pash->cbSrcLength < was->drvInst.pwfxSrc->nBlockAlign) {
WARN("source smaller than block align (%d < %d)\n",
pash->cbSrcLength, was->drvInst.pwfxSrc->nBlockAlign);
return pash->cbSrcLength ? ACMERR_NOTPOSSIBLE : MMSYSERR_INVALPARAM;
}
/* Note: the ACMSTREAMHEADER and ACMDRVSTREAMHEADER structs are of same
* size. some fields are private to msacm internals, and are exposed

View File

@ -591,14 +591,19 @@ static void test_prepareheader(void)
hdr.cbDstLength = sizeof(pcm);
mr = acmStreamPrepareHeader(has, &hdr, 0);
todo_wine
ok(mr == MMSYSERR_INVALPARAM, "expected 0x0b, got 0x%x\n", mr);
hdr.cbSrcLength = src->wfx.nBlockAlign - 1; /* less than block align */
mr = acmStreamPrepareHeader(has, &hdr, 0);
todo_wine
ok(mr == ACMERR_NOTPOSSIBLE, "expected 0x200, got 0x%x\n", mr);
hdr.cbSrcLength = src->wfx.nBlockAlign + 1; /* more than block align */
mr = acmStreamPrepareHeader(has, &hdr, 0);
ok(mr == MMSYSERR_NOERROR, "prepare failed: 0x%x\n", mr);
mr = acmStreamUnprepareHeader(has, &hdr, 0);
ok(mr == MMSYSERR_NOERROR, "unprepare failed: 0x%x\n", mr);
hdr.cbSrcLength = src->wfx.nBlockAlign;
mr = acmStreamPrepareHeader(has, &hdr, 1); /* invalid use of reserved parameter */
ok(mr == MMSYSERR_INVALFLAG, "expected 0x0a, got 0x%x\n", mr);
@ -674,7 +679,6 @@ todo_wine
hdr.pbDst = pcm;
hdr.cbDstLength = -4;
mr = acmStreamPrepareHeader(has, &hdr, 0);
todo_wine {
ok(mr == ACMERR_NOTPOSSIBLE, "expected 0x200, got 0x%x\n", mr);
ok(hdr.fdwStatus == 0, "expected 0, got 0x%x\n", hdr.fdwStatus);
@ -687,7 +691,7 @@ todo_wine {
mr = acmStreamUnprepareHeader(has, &hdr, 0);
ok(mr == ACMERR_UNPREPARED, "expected 0x202, got 0x%x\n", mr);
}
/* Less output space than required */
memset(&hdr, 0, sizeof(hdr));
hdr.cbStruct = sizeof(hdr);