From 93a2c3305190ca87cc1a6c98868c251ef67c3f37 Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Sat, 14 Jul 2018 05:09:27 +0200 Subject: auth-filter: do not write more than we've read Signed-off-by: Jason A. Donenfeld --- cgit.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cgit.c b/cgit.c index e2d7891..fda0aa4 100644 --- a/cgit.c +++ b/cgit.c @@ -659,13 +659,13 @@ static inline void open_auth_filter(const char *function) static inline void authenticate_post(void) { char buffer[MAX_AUTHENTICATION_POST_BYTES]; - unsigned int len; + ssize_t len; open_auth_filter("authenticate-post"); len = ctx.env.content_length; if (len > MAX_AUTHENTICATION_POST_BYTES) len = MAX_AUTHENTICATION_POST_BYTES; - if (read(STDIN_FILENO, buffer, len) < 0) + if ((len = read(STDIN_FILENO, buffer, len)) < 0) die_errno("Could not read POST from stdin"); if (write(STDOUT_FILENO, buffer, len) < 0) die_errno("Could not write POST to stdout"); -- cgit v1.2.3-57-g22cb