gpg-interface: fix const-correctness of "eol" pointer
authorJeff King <peff@peff.net>
Fri, 13 Apr 2018 21:18:33 +0000 (15:18 -0600)
committerJunio C Hamano <gitster@pobox.com>
Mon, 16 Apr 2018 05:15:03 +0000 (14:15 +0900)
We accidentally shed the "const" of our buffer by passing it
through memchr. Let's fix that, and while we're at it, move
our variable declaration inside the loop, which is the only
place that uses it.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Ben Toews <mastahyeti@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
gpg-interface.c
index ac852ad4b9d5582165d1e5874123300067cb28c6..3414af38b9d1b7ff8be0f3d24e9086a1059b1717 100644 (file)
@@ -103,11 +103,10 @@ void print_signature_buffer(const struct signature_check *sigc, unsigned flags)
 
 size_t parse_signature(const char *buf, size_t size)
 {
-       char *eol;
        size_t len = 0;
        while (len < size && !starts_with(buf + len, PGP_SIGNATURE) &&
                        !starts_with(buf + len, PGP_MESSAGE)) {
-               eol = memchr(buf + len, '\n', size - len);
+               const char *eol = memchr(buf + len, '\n', size - len);
                len += eol ? eol - (buf + len) + 1 : size - len;
        }
        return len;