summaryrefslogtreecommitdiff
path: root/gpg-interface.c
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2018-04-13 21:18:33 (GMT)
committerJunio C Hamano <gitster@pobox.com>2018-04-16 05:15:03 (GMT)
commit17ef3a421e0a1019592a0b14b95f09df61730071 (patch)
tree455f977598f0a91ea39a9d1ac748b2bf9cf88d94 /gpg-interface.c
parente6fa6cde5bec648f1b8fd7e3f9e5939c5093985a (diff)
downloadgit-17ef3a421e0a1019592a0b14b95f09df61730071.zip
git-17ef3a421e0a1019592a0b14b95f09df61730071.tar.gz
git-17ef3a421e0a1019592a0b14b95f09df61730071.tar.bz2
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 <peff@peff.net> Signed-off-by: Ben Toews <mastahyeti@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'gpg-interface.c')
-rw-r--r--gpg-interface.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/gpg-interface.c b/gpg-interface.c
index ac852ad..3414af3 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;