Skip to content

Commit

Permalink
sha1_to_hex: properly terminate the SHA1
Browse files Browse the repository at this point in the history
sha1_to_hex() returns a pointer to a static buffer. Some of its users
modify that buffer by appending a newline character. Other users rely
on the fact that you can call

	printf("%s", sha1_to_hex(sha1));

Just to be on the safe side, terminate the SHA1 in sha1_to_hex().

Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Signed-off-by: Junio C Hamano <junkio@cox.net>
  • Loading branch information
Johannes Schindelin authored and Junio C Hamano committed Dec 22, 2005
1 parent a14c225 commit 1e80e04
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions sha1_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ char * sha1_to_hex(const unsigned char *sha1)
*buf++ = hex[val >> 4];
*buf++ = hex[val & 0xf];
}
*buf = '\0';

return buffer;
}

Expand Down

0 comments on commit 1e80e04

Please sign in to comment.