Skip to content

Commit 8a45589

Browse files
committed
compat/winansi: check result before using Name field
NtQueryObject can return a success but fill out no name. In those situations, it will set the last argument to the size of the passed in struct, that being 16, to indicate that the name field is NULL. Without this change, using git compiled for Windows under wine in certain circumstances can result in a crash due to a null pointer dereference. Signed-off-by: Christopher Degawa <[email protected]>
1 parent 3260e2e commit 8a45589

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

compat/winansi.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -573,6 +573,8 @@ static void detect_msys_tty(int fd)
573573
if (!NT_SUCCESS(NtQueryObject(h, ObjectNameInformation,
574574
buffer, sizeof(buffer) - 2, &result)))
575575
return;
576+
if (result <= sizeof(*nameinfo))
577+
return;
576578
name = nameinfo->Name.Buffer;
577579
name[nameinfo->Name.Length / sizeof(*name)] = 0;
578580

0 commit comments

Comments
 (0)