If attrib is called without any parameter the variable originalname is used uninitialized.
Signed-off-by: Bernhard Übelacker bernhardu@mailbox.org --- C:>attrib wine: Unhandled page fault on write access to 000000007B027406 at address 0000000000402937 (thread 0110), starting debugger... Unhandled exception: page fault on write access to 0x7b027406 in 64-bit code (0x0000000000402937). ... Backtrace: =>0 0x0000000000402937 wmain+0x197(argc=<is not available>, argv=<is not available>) [Z:\home\bernhard\data\entwicklung\2021\wine\wine-git\wine-git\programs\attrib\attrib.c:295] in attrib (0x0000000000000000) 1 0x0000000000403455 wmainCRTStartup+0x64() [Z:\home\bernhard\data\entwicklung\2021\wine\wine-git\wine-git\dlls\msvcrt\crt_wmain.c:58] in attrib (0x0000000000000000) 2 0x000000007b62c7a9 BaseThreadInitThunk+0x8(unknown=<is not available>, entry=<is not available>, arg=<is not available>) [Z:\home\bernhard\data\entwicklung\2021\wine\wine-git\wine-git\dlls\kernel32\thread.c:61] in kernel32 (0x0000000000000000) 3 0x000000007bc56ee3 RtlUserThreadStart+0x82(entry=0x4033f0, arg=0x3f0000) [Z:\home\bernhard\data\entwicklung\2021\wine\wine-git\wine-git\dlls\ntdll\thread.c:241] in ntdll (0x0000000000000000) 0x0000000000402937 wmain+0x197 [Z:\home\bernhard\data\entwicklung\2021\wine\wine-git\wine-git\programs\attrib\attrib.c:295] in attrib: movw %r15w,(%r8) 295 *namepart = 0; --- programs/attrib/attrib.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/programs/attrib/attrib.c b/programs/attrib/attrib.c index 4813443449b..4ebcd2b8024 100644 --- a/programs/attrib/attrib.c +++ b/programs/attrib/attrib.c @@ -236,7 +236,7 @@ static BOOL ATTRIB_processdirectory(const WCHAR *rootdir, const WCHAR *filespec, int __cdecl wmain(int argc, WCHAR *argv[]) { WCHAR name[MAX_PATH]; - WCHAR *namepart; + WCHAR *namepart = 0; WCHAR curdir[MAX_PATH]; WCHAR originalname[MAX_PATH]; DWORD attrib_set = 0; @@ -252,7 +252,8 @@ int __cdecl wmain(int argc, WCHAR *argv[]) }
/* By default all files from current directory are taken into account */ - lstrcpyW(name, L"*"); + GetCurrentDirectoryW(ARRAY_SIZE(originalname), originalname); + lstrcatW(originalname, L"\*");
while (i < argc) { WCHAR *param = argv[i++];