]> git.cameronkatri.com Git - cgit.git/commitdiff
auth-filter: do not write more than we've read
authorJason A. Donenfeld <Jason@zx2c4.com>
Sat, 14 Jul 2018 03:09:27 +0000 (05:09 +0200)
committerJason A. Donenfeld <Jason@zx2c4.com>
Sat, 14 Jul 2018 03:09:27 +0000 (05:09 +0200)
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
cgit.c

diff --git a/cgit.c b/cgit.c
index e2d789101f302a6ad4b580146e1615968a7a91e9..fda0aa4b5ff87fa95690f95698406c661ba8f63f 100644 (file)
--- 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");