Subject: [PATCH v2 07/16] contrib/git-credential-gnome-keyring.c: ensure buffer is non-empty before accessing

From: Brandon Casey <[email-masked]>
Date: Mon, 23 Sep 2013 11:49:08 -0700

From: Brandon Casey <[email-masked]>

Ensure buffer length is non-zero before attempting to access the last
element.

Signed-off-by: Brandon Casey <[email-masked]>
---
 contrib/credential/gnome-keyring/git-credential-gnome-keyring.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/contrib/credential/gnome-keyring/git-credential-gnome-keyring.c b/contrib/credential/gnome-keyring/git-credential-gnome-keyring.c
index b9bb794..0d2c55e 100644
--- a/contrib/credential/gnome-keyring/git-credential-gnome-keyring.c
+++ b/contrib/credential/gnome-keyring/git-credential-gnome-keyring.c
@@ -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)
-- 
1.8.4.rc4.6.g5555d19

-----------------------------------------------------------------------------------
This email message is for the sole use of the intended recipient(s) and may contain
confidential information.  Any unauthorized review, use, disclosure or distribution
is prohibited.  If you are not the intended recipient, please contact the sender by
reply email and destroy all copies of the original message.
-----------------------------------------------------------------------------------