Signed-off-by: Gijs Vermeulen gijsvrm@gmail.com --- dlls/winmm/mmio.c | 3 +++ dlls/winmm/tests/mmio.c | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/dlls/winmm/mmio.c b/dlls/winmm/mmio.c index 1255cf69da2..1d755ea82b8 100644 --- a/dlls/winmm/mmio.c +++ b/dlls/winmm/mmio.c @@ -650,7 +650,10 @@ static HMMIO MMIO_Open(LPSTR szFileName, MMIOINFO* refmminfo, DWORD dwOpenFlags, if (GetFullPathNameA(szFileName, sizeof(buffer), buffer, NULL) >= sizeof(buffer)) return (HMMIO)FALSE; if ((dwOpenFlags & MMIO_EXIST) && (GetFileAttributesA(buffer) == INVALID_FILE_ATTRIBUTES)) + { + refmminfo->wErrorRet = MMIOERR_FILENOTFOUND; return (HMMIO)FALSE; + } strcpy(szFileName, buffer); return (HMMIO)TRUE; } diff --git a/dlls/winmm/tests/mmio.c b/dlls/winmm/tests/mmio.c index a232070064c..cfe917e8b38 100644 --- a/dlls/winmm/tests/mmio.c +++ b/dlls/winmm/tests/mmio.c @@ -565,7 +565,7 @@ static void test_mmioOpen_create(void) info.wErrorRet = 0xdead; hmmio = mmioOpenW(buffer, &info, MMIO_EXIST); ok(hmmio == (HMMIO)FALSE, "file should exist\n"); - todo_wine ok(info.wErrorRet == MMIOERR_FILENOTFOUND, "got error %#x\n", info.wErrorRet); + ok(info.wErrorRet == MMIOERR_FILENOTFOUND, "got error %#x\n", info.wErrorRet);
ret = DeleteFileA("test_mmio_path"); ok(!ret, "expected failure\n");
Signed-off-by: Gijs Vermeulen gijsvrm@gmail.com --- dlls/winmm/mmio.c | 4 ++-- dlls/winmm/tests/mmio.c | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/dlls/winmm/mmio.c b/dlls/winmm/mmio.c index 1d755ea82b8..3ad29a5fe92 100644 --- a/dlls/winmm/mmio.c +++ b/dlls/winmm/mmio.c @@ -643,7 +643,7 @@ static HMMIO MMIO_Open(LPSTR szFileName, MMIOINFO* refmminfo, DWORD dwOpenFlags, }
if (dwOpenFlags & (MMIO_PARSE|MMIO_EXIST)) { - char buffer[MAX_PATH]; + char buffer[128];
if (!szFileName) return (HMMIO)FALSE; @@ -744,7 +744,7 @@ HMMIO WINAPI mmioOpenW(LPWSTR szFileName, MMIOINFO* lpmmioinfo, if (szFileName) { INT len = WideCharToMultiByte( CP_ACP, 0, szFileName, -1, NULL, 0, NULL, NULL ); - if (len < MAX_PATH) len = MAX_PATH; + if (len < 128) len = 128; szFn = HeapAlloc( GetProcessHeap(), 0, len ); if (!szFn) return NULL; WideCharToMultiByte( CP_ACP, 0, szFileName, -1, szFn, len, NULL, NULL ); diff --git a/dlls/winmm/tests/mmio.c b/dlls/winmm/tests/mmio.c index cfe917e8b38..5fe81e58d3d 100644 --- a/dlls/winmm/tests/mmio.c +++ b/dlls/winmm/tests/mmio.c @@ -534,7 +534,7 @@ static void test_mmioOpen_create(void) wcscpy(buffer, long_filename); info.wErrorRet = 0xdead; hmmio = mmioOpenW(buffer, &info, MMIO_PARSE); - todo_wine ok(hmmio == (HMMIO)FALSE, "failed to parse file name, error %#x\n", info.wErrorRet); + ok(hmmio == (HMMIO)FALSE, "failed to parse file name, error %#x\n", info.wErrorRet); todo_wine ok(info.wErrorRet == MMIOERR_OUTOFMEMORY, "got error %#x\n", info.wErrorRet); wcscpy(expect, temp_dir); wcscat(expect, long_filename); @@ -544,10 +544,10 @@ static void test_mmioOpen_create(void) WideCharToMultiByte(CP_ACP, 0, long_filename, -1, bufferA, sizeof(bufferA), NULL, NULL); info.wErrorRet = 0xdead; hmmio = mmioOpenA(bufferA, &info, MMIO_PARSE); - todo_wine ok(hmmio == (HMMIO)FALSE, "failed to parse file name, error %#x\n", info.wErrorRet); + ok(hmmio == (HMMIO)FALSE, "failed to parse file name, error %#x\n", info.wErrorRet); todo_wine ok(info.wErrorRet == MMIOERR_OUTOFMEMORY, "got error %#x\n", info.wErrorRet); WideCharToMultiByte(CP_ACP, 0, long_filename, -1, expectA, sizeof(expectA), NULL, NULL); - todo_wine ok(!strcmp(bufferA, expectA), "expected %s, got %s\n", debugstr_a(expectA), debugstr_a(bufferA)); + ok(!strcmp(bufferA, expectA), "expected %s, got %s\n", debugstr_a(expectA), debugstr_a(bufferA));
wcscpy(buffer, L"test_mmio_path"); hmmio = mmioOpenW(buffer, &info, MMIO_WRITE);
Signed-off-by: Gijs Vermeulen gijsvrm@gmail.com --- dlls/winmm/mmio.c | 3 +++ dlls/winmm/tests/mmio.c | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/dlls/winmm/mmio.c b/dlls/winmm/mmio.c index 3ad29a5fe92..7882dc1c2f9 100644 --- a/dlls/winmm/mmio.c +++ b/dlls/winmm/mmio.c @@ -648,7 +648,10 @@ static HMMIO MMIO_Open(LPSTR szFileName, MMIOINFO* refmminfo, DWORD dwOpenFlags, if (!szFileName) return (HMMIO)FALSE; if (GetFullPathNameA(szFileName, sizeof(buffer), buffer, NULL) >= sizeof(buffer)) + { + refmminfo->wErrorRet = MMIOERR_OUTOFMEMORY; return (HMMIO)FALSE; + } if ((dwOpenFlags & MMIO_EXIST) && (GetFileAttributesA(buffer) == INVALID_FILE_ATTRIBUTES)) { refmminfo->wErrorRet = MMIOERR_FILENOTFOUND; diff --git a/dlls/winmm/tests/mmio.c b/dlls/winmm/tests/mmio.c index 5fe81e58d3d..ae9d4b6aeeb 100644 --- a/dlls/winmm/tests/mmio.c +++ b/dlls/winmm/tests/mmio.c @@ -535,7 +535,7 @@ static void test_mmioOpen_create(void) info.wErrorRet = 0xdead; hmmio = mmioOpenW(buffer, &info, MMIO_PARSE); ok(hmmio == (HMMIO)FALSE, "failed to parse file name, error %#x\n", info.wErrorRet); - todo_wine ok(info.wErrorRet == MMIOERR_OUTOFMEMORY, "got error %#x\n", info.wErrorRet); + ok(info.wErrorRet == MMIOERR_OUTOFMEMORY, "got error %#x\n", info.wErrorRet); wcscpy(expect, temp_dir); wcscat(expect, long_filename); expect[127] = 0; @@ -545,7 +545,7 @@ static void test_mmioOpen_create(void) info.wErrorRet = 0xdead; hmmio = mmioOpenA(bufferA, &info, MMIO_PARSE); ok(hmmio == (HMMIO)FALSE, "failed to parse file name, error %#x\n", info.wErrorRet); - todo_wine ok(info.wErrorRet == MMIOERR_OUTOFMEMORY, "got error %#x\n", info.wErrorRet); + ok(info.wErrorRet == MMIOERR_OUTOFMEMORY, "got error %#x\n", info.wErrorRet); WideCharToMultiByte(CP_ACP, 0, long_filename, -1, expectA, sizeof(expectA), NULL, NULL); ok(!strcmp(bufferA, expectA), "expected %s, got %s\n", debugstr_a(expectA), debugstr_a(bufferA));
Signed-off-by: Gijs Vermeulen gijsvrm@gmail.com --- dlls/winmm/mmio.c | 7 +++++++ dlls/winmm/tests/mmio.c | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/dlls/winmm/mmio.c b/dlls/winmm/mmio.c index 7882dc1c2f9..db210a29bec 100644 --- a/dlls/winmm/mmio.c +++ b/dlls/winmm/mmio.c @@ -755,6 +755,13 @@ HMMIO WINAPI mmioOpenW(LPWSTR szFileName, MMIOINFO* lpmmioinfo,
ret = MMIO_Open(szFn, lpmmioinfo, dwOpenFlags, TRUE);
+ if (szFileName) + { + INT len = MultiByteToWideChar( CP_ACP, 0, szFn, -1, NULL, 0 ); + if (len < 128) len = 128; + MultiByteToWideChar( CP_ACP, 0, szFn, -1, szFileName, len ); + } + HeapFree(GetProcessHeap(), 0, szFn); return ret; } diff --git a/dlls/winmm/tests/mmio.c b/dlls/winmm/tests/mmio.c index ae9d4b6aeeb..47788510910 100644 --- a/dlls/winmm/tests/mmio.c +++ b/dlls/winmm/tests/mmio.c @@ -559,7 +559,7 @@ static void test_mmioOpen_create(void) ok(hmmio == (HMMIO)TRUE, "failed to parse file name, error %#x\n", info.wErrorRet); wcscpy(expect, temp_dir); wcscat(expect, L"test_mmio_path"); - todo_wine ok(!wcscmp(buffer, expect), "expected %s, got %s\n", debugstr_w(expect), debugstr_w(buffer)); + ok(!wcscmp(buffer, expect), "expected %s, got %s\n", debugstr_w(expect), debugstr_w(buffer));
wcscpy(buffer, L"test_mmio_path"); info.wErrorRet = 0xdead;
On Mon, Jan 18, 2021 at 09:45:34PM +0100, Gijs Vermeulen wrote:
diff --git a/dlls/winmm/mmio.c b/dlls/winmm/mmio.c index 7882dc1c2f9..db210a29bec 100644 --- a/dlls/winmm/mmio.c +++ b/dlls/winmm/mmio.c @@ -755,6 +755,13 @@ HMMIO WINAPI mmioOpenW(LPWSTR szFileName, MMIOINFO* lpmmioinfo,
ret = MMIO_Open(szFn, lpmmioinfo, dwOpenFlags, TRUE);
- if (szFileName)
- {
INT len = MultiByteToWideChar( CP_ACP, 0, szFn, -1, NULL, 0 );
if (len < 128) len = 128;
MultiByteToWideChar( CP_ACP, 0, szFn, -1, szFileName, len );
- }
- HeapFree(GetProcessHeap(), 0, szFn); return ret;
}
Are you sure we want to write to szFileName in all cases? Does Windows do that? It seems possible an application would pass in something const or write protected, which we won't want to touch.
Also I think you can just pass 128 in all cases, there's no reason to get the destination length.
Andrew