https://git.reactos.org/?p=reactos.git;a=commitdiff;h=b30a8a08684f9eb5f97cf…
commit b30a8a08684f9eb5f97cffcb4f36c55c85823377
Author: Thamatip Chitpong <tangaming123456(a)outlook.com>
AuthorDate: Wed Jun 14 09:32:52 2023 +0700
Commit: Stanislav Motylkov <x86corez(a)gmail.com>
CommitDate: Thu Jul 6 13:36:22 2023 +0300
[WINESYNC][WINMM] Properly handle mmioRead/mmioWrite in case of errors
In C, an inequality comparison between a signed and an unsigned integer
ends up with an unsigned comparison.
Wine-Bug:
https://bugs.winehq.org/show_bug.cgi?id=52628
Wine commit: 0de8d01b09b1cc7ca34f7ae3890b4a416ff801fe
author: Eric Pouech <eric.pouech(a)gmail.com>
Wed, 30 Mar 2022 12:57:44 +0000 (14:57 +0200)
committer: Alexandre Julliard <julliard(a)winehq.org>
Fri, 1 Apr 2022 20:59:40 +0000 (22:59 +0200)
---
dll/win32/winmm/mmio.c | 4 ++--
dll/win32/winmm/playsound.c | 6 ++++--
2 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/dll/win32/winmm/mmio.c b/dll/win32/winmm/mmio.c
index 5e86722e747..9182d3b800c 100644
--- a/dll/win32/winmm/mmio.c
+++ b/dll/win32/winmm/mmio.c
@@ -1161,7 +1161,7 @@ MMRESULT WINAPI mmioDescend(HMMIO hmmio, LPMMCKINFO lpck,
LONG ix;
ix = mmioRead(hmmio, (LPSTR)lpck, 3 * sizeof(DWORD));
- if (ix < 2*sizeof(DWORD))
+ if (ix < 0 || ix < 2*sizeof(DWORD))
{
mmioSeek(hmmio, dwOldPos, SEEK_SET);
WARN("return ChunkNotFound\n");
@@ -1263,7 +1263,7 @@ MMRESULT WINAPI mmioCreateChunk(HMMIO hmmio, MMCKINFO* lpck, UINT
uFlags)
ix = mmioWrite(hmmio, (LPSTR)lpck, size);
TRACE("after mmioWrite ix = %d req = %d, errno = %d\n", ix, size, errno);
- if (ix < size) {
+ if (ix != size) {
mmioSeek(hmmio, dwOldPos, SEEK_SET);
WARN("return CannotWrite\n");
return MMIOERR_CANNOTWRITE;
diff --git a/dll/win32/winmm/playsound.c b/dll/win32/winmm/playsound.c
index f71cbd32a21..b599073a2db 100644
--- a/dll/win32/winmm/playsound.c
+++ b/dll/win32/winmm/playsound.c
@@ -428,6 +428,7 @@ static BOOL proc_PlaySound(WINE_PLAYSOUND *wps)
LPWAVEHDR waveHdr = NULL;
INT count, bufsize, left, index;
struct playsound_data s;
+ LONG r;
s.hEvent = 0;
@@ -451,8 +452,9 @@ static BOOL proc_PlaySound(WINE_PLAYSOUND *wps)
lpWaveFormat = HeapAlloc(GetProcessHeap(), 0, mmckInfo.cksize);
if (!lpWaveFormat)
goto errCleanUp;
- if (mmioRead(wps->hmmio, (HPSTR)lpWaveFormat, mmckInfo.cksize) <
sizeof(PCMWAVEFORMAT))
- goto errCleanUp;
+ r = mmioRead(wps->hmmio, (HPSTR)lpWaveFormat, mmckInfo.cksize);
+ if (r < 0 || r < sizeof(PCMWAVEFORMAT))
+ goto errCleanUp;
TRACE("wFormatTag=%04X !\n", lpWaveFormat->wFormatTag);
TRACE("nChannels=%d\n", lpWaveFormat->nChannels);