auth-filter: do not write more than we've read Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Jason A. Donenfeld Jason@zx2c4.com
Sat, 14 Jul 2018 05:09:27 +0200
1 files changed,
2 insertions(+),
2 deletions(-)
jump to
M
cgit.c
→
cgit.c
@@ -659,13 +659,13 @@ /* The filter is expected to spit out "Status: " and all headers. */
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");