Skip to content

Commit 4755d7d

Browse files
avargitster
authored andcommitted
refs API: don't expose "errno" in run_transaction_hook()
In run_transaction_hook() we've checked errno since 6754159 (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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 6582bd3 commit 4755d7d

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

refs.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2096,8 +2096,11 @@ static int run_transaction_hook(struct ref_transaction *transaction,
20962096
update->refname);
20972097

20982098
if (write_in_full(proc.in, buf.buf, buf.len) < 0) {
2099-
if (errno != EPIPE)
2099+
if (errno != EPIPE) {
2100+
/* Don't leak errno outside this API */
2101+
errno = 0;
21002102
ret = -1;
2103+
}
21012104
break;
21022105
}
21032106
}

0 commit comments

Comments
 (0)