Thread (44 messages) 44 messages, 2 authors, 2021-10-16
STALE1685d
Revisions (2)
  1. v1 current
  2. v2 [diff vs current]

[PATCH 18/20] refs API: don't expose "errno" in run_transaction_hook()

From: Ævar Arnfjörð Bjarmason <hidden>
Date: 2021-10-14 00:07:19
Subsystem: the rest · Maintainer: Linus Torvalds

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 <redacted>
---
 refs.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/refs.c b/refs.c
index 16f8220b108..9aa41b55c7b 100644
--- a/refs.c
+++ b/refs.c
@@ -2095,8 +2095,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;
 		}
 	}
-- 
2.33.1.1346.g48288c3c089
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help