diff options
author | Junio C Hamano <gitster@pobox.com> | 2022-05-31 19:10:35 -0700 |
---|---|---|
committer | Johannes Schindelin <johannes.schindelin@gmx.de> | 2023-03-22 18:00:34 +0100 |
commit | 0a1dc55c40533695ab595805675e08a539b20a20 (patch) | |
tree | c4ea38b96ab7e23378554707f700b5239088603a | |
parent | 394a759d2b5f0a1a1908c820cf142f45cb78718c (diff) | |
parent | 321854ac464bbc85ff2afe089c4a56505a1c9e25 (diff) | |
download | git-0a1dc55c40533695ab595805675e08a539b20a20.tar.gz |
Merge branch 'backport/js/ci-gcc-12-fixes'
Fixes real problems noticed by gcc 12 and works around false
positives.
* js/ci-gcc-12-fixes:
nedmalloc: avoid new compile error
compat/win32/syslog: fix use-after-realloc
-rw-r--r-- | builtin/clone.c | 9 | ||||
-rw-r--r-- | compat/nedmalloc/nedmalloc.c | 1 | ||||
-rw-r--r-- | compat/win32/syslog.c | 2 |
3 files changed, 11 insertions, 1 deletions
diff --git a/builtin/clone.c b/builtin/clone.c index c042b2e256..9ab17cab19 100644 --- a/builtin/clone.c +++ b/builtin/clone.c @@ -251,6 +251,15 @@ static char *guess_dir_name(const char *repo, int is_bundle, int is_bare) } /* + * It should not be possible to overflow `ptrdiff_t` by passing in an + * insanely long URL, but GCC does not know that and will complain + * without this check. + */ + if (end - start < 0) + die(_("No directory name could be guessed.\n" + "Please specify a directory on the command line")); + + /* * Strip trailing port number if we've got only a * hostname (that is, there is no dir separator but a * colon). This check is required such that we do not diff --git a/compat/nedmalloc/nedmalloc.c b/compat/nedmalloc/nedmalloc.c index 1cc31c3502..141c30f07f 100644 --- a/compat/nedmalloc/nedmalloc.c +++ b/compat/nedmalloc/nedmalloc.c @@ -323,7 +323,6 @@ static NOINLINE void RemoveCacheEntries(nedpool *p, threadcache *tc, unsigned in } static void DestroyCaches(nedpool *p) THROWSPEC { - if(p->caches) { threadcache *tc; int n; diff --git a/compat/win32/syslog.c b/compat/win32/syslog.c index 161978d720..1f8d8934cc 100644 --- a/compat/win32/syslog.c +++ b/compat/win32/syslog.c @@ -43,6 +43,7 @@ void syslog(int priority, const char *fmt, ...) va_end(ap); while ((pos = strstr(str, "%1")) != NULL) { + size_t offset = pos - str; char *oldstr = str; str = realloc(str, st_add(++str_len, 1)); if (!str) { @@ -50,6 +51,7 @@ void syslog(int priority, const char *fmt, ...) warning_errno("realloc failed"); return; } + pos = str + offset; memmove(pos + 2, pos + 1, strlen(pos)); pos[1] = ' '; } |