git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] mingw: consider that UNICODE_STRING::Length counts bytes

From
Junio C Hamano <gitster@pobox.com>
Date
Dec 19, 2016, 21:57 UTC
Message-ID
<xmqqtw9zmvjq.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<1482183120-21592-1-git-send-email-max@max630.net>
Max Kirillov <max@max630.net> writes:
Show 8 quoted lines
> UNICODE_STRING::Length field means size of buffer in bytes[1], despite of buffer
> itself being array of wchar_t. Because of that terminating zero is placed twice
> as far. Fix it.
>
> [1] https://msdn.microsoft.com/en-us/library/windows/desktop/aa380518.aspx
>
> Signed-off-by: Max Kirillov <max@max630.net>
> ---

Max, I see this is a resend from a few days ago. I suspect that we are in a slow season, so there may be longer delay until we see responses to a patch.

I will wait until taking any patch to files specific to MS Windows platform (compat/win*, compat/mingw*, and compat/vcbuild*) without first seeing it reviewed and acked by either of the two Johannes's (well, there might be other people in addition to those two, whose Acked-by/Reviewed-by I should be trusting; if that is the case, it only shows how unqualified I would be as the first contact to be on the To: line of such a patch).

I do not mind "see the patch, ping Johanneses as needed, wait and then apply it to my tree" flow, but I also wonder if the process can be made more efficient. Dscho (one of the Johanneses) gets many patches specific to Windows port via the Git-for-Windows project and then "upstreams" by forwarding with his sign-off in my direction, and I do not mind that flow, either. Whichever one is the most efficient for all three parties involved is fine by me, but if one is preferred over the other, perhaps I should write it down in the "notes from the maintainer" or somewhere?

Dscho, J6t, what do you think?
Thanks.
Show 20 quoted lines
> Access outside of buffer was very unlikely (for that user needed to redirect
> standard fd to a file with path longer than ~250 symbols), it still did not
> seem to do any harm, and otherwise it did not break because only substring is
> checked, but it was still incorrect.
>  compat/winansi.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/compat/winansi.c b/compat/winansi.c
> index 3be60ce..6b4f736 100644
> --- a/compat/winansi.c
> +++ b/compat/winansi.c
> @@ -553,7 +553,7 @@ static void detect_msys_tty(int fd)
>  			buffer, sizeof(buffer) - 2, &result)))
>  		return;
>  	name = nameinfo->Name.Buffer;
> -	name[nameinfo->Name.Length] = 0;
> +	name[nameinfo->Name.Length / sizeof(*name)] = 0;
>  
>  	/* check if this could be a MSYS2 pty pipe ('msys-XXXX-ptyN-XX') */
>  	if (!wcsstr(name, L"msys-") || !wcsstr(name, L"-pty"))
Previous: Max KirillovNext: Max Kirillov
Message 2 of 5 in “mingw: consider that UNICODE_STRING::Length counts bytes”
  1. mingw: consider that UNICODE_STRING::Length counts bytesMax Kirillov, Dec 19, 2016
  2. Junio C HamanoDec 19, 2016
  3. Max KirillovDec 20, 2016
  4. Johannes SchindelinDec 20, 2016
  5. Junio C HamanoDec 20, 2016

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.