mirror of
https://github.com/git/git.git
synced 2026-06-09 15:37:49 +02:00
contrib/git-credential-gnome-keyring.c: ensure buffer is non-empty before accessing
Ensure buffer length is non-zero before attempting to access the last element. Signed-off-by: Brandon Casey <drafnel@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
fb2763746f
commit
73bbc0796b
@@ -314,7 +314,7 @@ static int credential_read(struct credential *c)
|
||||
{
|
||||
line_len = strlen(buf);
|
||||
|
||||
if (buf[line_len-1]=='\n')
|
||||
if (line_len && buf[line_len-1] == '\n')
|
||||
buf[--line_len]='\0';
|
||||
|
||||
if (!line_len)
|
||||
|
||||
Reference in New Issue
Block a user