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++];
Signed-off-by: Bernhard Übelacker bernhardu@mailbox.org --- programs/cmd/tests/test_builtins.cmd | 1 + programs/cmd/tests/test_builtins.cmd.exp | 1 + 2 files changed, 2 insertions(+)
diff --git a/programs/cmd/tests/test_builtins.cmd b/programs/cmd/tests/test_builtins.cmd index 7cd806c3d54..47b028207ac 100644 --- a/programs/cmd/tests/test_builtins.cmd +++ b/programs/cmd/tests/test_builtins.cmd @@ -2360,6 +2360,7 @@ echo ------------ Testing attrib ------------ rem FIXME Add tests for archive, hidden and system attributes + mixed attributes modifications mkdir foobar & cd foobar echo foo original contents> foo +attrib attrib foo echo > bar echo --- read-only attribute diff --git a/programs/cmd/tests/test_builtins.cmd.exp b/programs/cmd/tests/test_builtins.cmd.exp index bf5fcddeb9d..4c7bc3e0c02 100644 --- a/programs/cmd/tests/test_builtins.cmd.exp +++ b/programs/cmd/tests/test_builtins.cmd.exp @@ -1431,6 +1431,7 @@ bar\baz removed @pwd@ ------------ Testing attrib ------------ A@spaces@@drive@@path@foobar\foo@or_broken@A I@spaces@@drive@@path@foobar\foo +A@spaces@@drive@@path@foobar\foo@or_broken@A I@spaces@@drive@@path@foobar\foo --- read-only attribute A R@spaces@@drive@@path@foobar\foo@or_broken@A R I@spaces@@drive@@path@foobar\foo foo