From: Jeff King Date: Fri, 13 Apr 2018 21:18:33 +0000 (-0600) Subject: gpg-interface: fix const-correctness of "eol" pointer X-Git-Tag: v2.18.0-rc0~84^2~2 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/17ef3a421e0a1019592a0b14b95f09df61730071?hp=--cc gpg-interface: fix const-correctness of "eol" pointer 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 Signed-off-by: Ben Toews Signed-off-by: Junio C Hamano --- 17ef3a421e0a1019592a0b14b95f09df61730071 diff --git a/gpg-interface.c b/gpg-interface.c index ac852ad4b9..3414af38b9 100644 --- a/gpg-interface.c +++ b/gpg-interface.c @@ -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;