Skip to content

Commit 17ef3a4

Browse files
peffgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Ben Toews <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent e6fa6cd commit 17ef3a4

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

gpg-interface.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,10 @@ void print_signature_buffer(const struct signature_check *sigc, unsigned flags)
103103

104104
size_t parse_signature(const char *buf, size_t size)
105105
{
106-
char *eol;
107106
size_t len = 0;
108107
while (len < size && !starts_with(buf + len, PGP_SIGNATURE) &&
109108
!starts_with(buf + len, PGP_MESSAGE)) {
110-
eol = memchr(buf + len, '\n', size - len);
109+
const char *eol = memchr(buf + len, '\n', size - len);
111110
len += eol ? eol - (buf + len) + 1 : size - len;
112111
}
113112
return len;

0 commit comments

Comments
 (0)