]> git.ipfire.org Git - thirdparty/git.git/commitdiff
refs API: don't expose "errno" in run_transaction_hook()
authorÆvar Arnfjörð Bjarmason <avarab@gmail.com>
Sat, 16 Oct 2021 09:39:25 +0000 (11:39 +0200)
committerJunio C Hamano <gitster@pobox.com>
Sat, 16 Oct 2021 18:17:04 +0000 (11:17 -0700)
In run_transaction_hook() we've checked errno since 67541597670 (refs:
implement reference transaction hook, 2020-06-19), let's reset errno
afterwards to make sure nobody using refs.c directly or indirectly
relies on it.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
refs.c

diff --git a/refs.c b/refs.c
index 43fe9e6d89dfe1843f624a6f06a023abd0a00538..e90c59539b45370caf80fce8297d32564077711e 100644 (file)
--- a/refs.c
+++ b/refs.c
@@ -2096,8 +2096,11 @@ static int run_transaction_hook(struct ref_transaction *transaction,
                            update->refname);
 
                if (write_in_full(proc.in, buf.buf, buf.len) < 0) {
-                       if (errno != EPIPE)
+                       if (errno != EPIPE) {
+                               /* Don't leak errno outside this API */
+                               errno = 0;
                                ret = -1;
+                       }
                        break;
                }
        }