From: Phillip Wood <phillip.wood123@gmail.com>
To: Derrick Stolee via GitGitGadget <gitgitgadget@gmail.com>,
git@vger.kernel.org
Cc: gitster@pobox.com, Derrick Stolee <derrickstolee@github.com>
Subject: Re: [PATCH] compat/win32: correct for incorrect compiler warning
Date: Thu, 21 Jul 2022 15:17:43 +0100 [thread overview]
Message-ID: <653c6a24-df30-2b06-4cf7-f01bd6012d55@gmail.com> (raw)
In-Reply-To: <pull.1294.git.1658256354725.gitgitgadget@gmail.com>
Hi Stolee
> 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
prev parent reply other threads:[~2022-07-21 14:17 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-19 18:45 [PATCH] compat/win32: correct for incorrect compiler warning Derrick Stolee via GitGitGadget
2022-07-19 19:48 ` Eric Sunshine
2022-07-19 20:01 ` Derrick Stolee
2022-07-19 20:13 ` Junio C Hamano
2022-07-21 14:17 ` Phillip Wood [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=653c6a24-df30-2b06-4cf7-f01bd6012d55@gmail.com \
--to=phillip.wood123@gmail.com \
--cc=derrickstolee@github.com \
--cc=git@vger.kernel.org \
--cc=gitgitgadget@gmail.com \
--cc=gitster@pobox.com \
--cc=phillip.wood@dunelm.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).