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

Re: [PATCH] compat/win32: correct for incorrect compiler warning

From
PWPhillip Wood <phillip.wood123@gmail.com>
Date
Jul 21, 2022, 14:17 UTC
Message-ID
<653c6a24-df30-2b06-4cf7-f01bd6012d55@gmail.com>
In-Reply-To
<pull.1294.git.1658256354725.gitgitgadget@gmail.com>
Hi Stolee
Show 11 quoted lines
> diff --git a/compat/win32/syslog.c b/compat/win32/syslog.c
> index 1f8d8934cc9..0af18d88825 100644
> --- a/compat/win32/syslog.c
> +++ b/compat/win32/syslog.c
> @@ -44,6 +44,7 @@ void syslog(int priority, const char *fmt, ...)
>   
>   	while ((pos = strstr(str, "%1")) != NULL) {
>   		size_t offset = pos - str;
> +		char *new_pos;
>   		char *oldstr = str;
>   		str = realloc(str, st_add(++str_len, 1));

Not related to your patch but this context line looks suspicious as str_len is incremented without checking for overflow. I did wonder if it should be using a post increment instead and was using the st_add() to check if that overflowed but str_len is an int so we'd still have undefined behavior.

Best Wishes
Phillip
Previous: Junio C Hamano
Message 5 of 5 in “compat/win32: correct for incorrect compiler warning”
  1. compat/win32: correct for incorrect compiler warningDerrick Stolee via GitGitGadget, Jul 19, 2022
  2. Eric SunshineJul 19, 2022
  3. Derrick StoleeJul 19, 2022
  4. Junio C HamanoJul 19, 2022
  5. Phillip WoodJul 21, 2022

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.