From: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com> To: git@vger.kernel.org Cc: "Junio C Hamano" <gitster@pobox.com>, "Derrick Stolee" <derrickstolee@github.com>, "Ævar Arnfjörð Bjarmason" <avarab@gmail.com> Subject: [RFC PATCH 1/2] object-file API: fix obscure unpack_loose_header() return Date: Thu, 19 May 2022 22:09:16 +0200 [thread overview] Message-ID: <RFC-patch-1.2-297bea05118-20220519T195055Z-avarab@gmail.com> (raw) In-Reply-To: <RFC-cover-0.2-00000000000-20220519T195055Z-avarab@gmail.com> Fix an obscure unpack_loose_header() return value. In my 5848fb11acd (object-file.c: return ULHR_TOO_LONG on "header too long", 2021-10-01) this API learned to return ULHR_TOO_LONG, but should not have done so in the case of parsing a long header where the terminating \0 cannot be found. We should return a ULHR_BAD in that case. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> --- cache.h | 3 +-- object-file.c | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/cache.h b/cache.h index 595582becc8..aa24d5a609f 100644 --- a/cache.h +++ b/cache.h @@ -1342,8 +1342,7 @@ int git_open_cloexec(const char *name, int flags); * "hdrbuf" argument is non-NULL. This is intended for use with * OBJECT_INFO_ALLOW_UNKNOWN_TYPE to extract the bad type for (error) * reporting. The full header will be extracted to "hdrbuf" for use - * with parse_loose_header(), ULHR_TOO_LONG will still be returned - * from this function to indicate that the header was too long. + * with parse_loose_header(). */ enum unpack_loose_header_result { ULHR_OK, diff --git a/object-file.c b/object-file.c index b5d1d12b68a..1babe9791f6 100644 --- a/object-file.c +++ b/object-file.c @@ -1301,7 +1301,7 @@ enum unpack_loose_header_result unpack_loose_header(git_zstream *stream, stream->next_out = buffer; stream->avail_out = bufsiz; } while (status != Z_STREAM_END); - return ULHR_TOO_LONG; + return ULHR_BAD; } static void *unpack_loose_rest(git_zstream *stream, -- 2.36.1.957.g2c13267e09b
next prev parent reply other threads:[~2022-05-19 20:09 UTC|newest] Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-04-21 20:14 [PATCH 0/4] Fix issues and a regression noted by valgrind Ævar Arnfjörð Bjarmason 2022-04-21 20:14 ` [PATCH 1/4] tests: make RUNTIME_PREFIX compatible with --valgrind Ævar Arnfjörð Bjarmason 2022-04-21 22:22 ` Junio C Hamano 2022-04-21 20:14 ` [PATCH 2/4] log test: skip a failing mkstemp() test under valgrind Ævar Arnfjörð Bjarmason 2022-04-21 20:14 ` [PATCH 3/4] commit-graph.c: don't assume that stat() succeeds Ævar Arnfjörð Bjarmason 2022-04-21 22:29 ` Junio C Hamano 2022-04-21 20:14 ` [PATCH 4/4] object-file: fix a unpack_loose_header() regression in 3b6a8db3b03 Ævar Arnfjörð Bjarmason 2022-04-21 22:39 ` Junio C Hamano 2022-04-22 8:21 ` Ævar Arnfjörð Bjarmason 2022-05-12 22:32 ` [PATCH v2 0/4] test fixes around valgrind Junio C Hamano 2022-05-12 22:32 ` [PATCH v2 1/4] tests: using custom GIT_EXEC_PATH breaks --valgrind tests Junio C Hamano 2022-05-12 22:32 ` [PATCH v2 2/4] log test: skip a failing mkstemp() test under valgrind Junio C Hamano 2022-05-12 22:32 ` [PATCH v2 3/4] commit-graph.c: don't assume that stat() succeeds Junio C Hamano 2022-05-12 22:32 ` [PATCH v2 4/4] object-file: fix a unpack_loose_header() regression in 3b6a8db3b03 Junio C Hamano 2022-05-12 23:39 ` Junio C Hamano 2022-05-16 14:59 ` Derrick Stolee 2022-05-19 20:09 ` [RFC PATCH 0/2] Alternate ab/valgrind-fixes fix-up Ævar Arnfjörð Bjarmason 2022-05-19 20:09 ` Ævar Arnfjörð Bjarmason [this message] 2022-05-19 20:09 ` [RFC PATCH 2/2] object-file API: have unpack_loose_header() return "int" again Ævar Arnfjörð Bjarmason 2022-05-20 4:27 ` Junio C Hamano
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 List information: http://vger.kernel.org/majordomo-info.html * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=RFC-patch-1.2-297bea05118-20220519T195055Z-avarab@gmail.com \ --to=avarab@gmail.com \ --cc=derrickstolee@github.com \ --cc=git@vger.kernel.org \ --cc=gitster@pobox.com \ --subject='Re: [RFC PATCH 1/2] object-file API: fix obscure unpack_loose_header() return' \ /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
Code repositories for project(s) associated with this inbox: https://80x24.org/mirrors/git.git 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 read-only IMAP folder(s) and NNTP newsgroup(s).