git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] hex: use unsigned index for ring buffer
@ 2016-10-23  9:00 René Scharfe
  2016-10-23  9:11 ` Jeff King
  0 siblings, 1 reply; 14+ messages in thread
From: René Scharfe @ 2016-10-23  9:00 UTC (permalink / raw)
  To: Git List; +Cc: Junio C Hamano, Jeff King

Overflow is defined for unsigned integers, but not for signed ones.
Make the ring buffer index in sha1_to_hex() unsigned to be on the
safe side.

Signed-off-by: Rene Scharfe <l.s.r@web.de>
---
Hard to trigger, but probably even harder to diagnose once someone
somehow manages to do it on some uncommon architecture.

 hex.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hex.c b/hex.c
index ab2610e..8c6c189 100644
--- a/hex.c
+++ b/hex.c
@@ -76,7 +76,7 @@ char *oid_to_hex_r(char *buffer, const struct object_id *oid)
 
 char *sha1_to_hex(const unsigned char *sha1)
 {
-	static int bufno;
+	static unsigned int bufno;
 	static char hexbuffer[4][GIT_SHA1_HEXSZ + 1];
 	return sha1_to_hex_r(hexbuffer[3 & ++bufno], sha1);
 }
-- 
2.10.1


^ permalink raw reply related	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2016-10-26 17:53 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-10-23  9:00 [PATCH] hex: use unsigned index for ring buffer René Scharfe
2016-10-23  9:11 ` Jeff King
2016-10-23 17:57   ` René Scharfe
2016-10-24 13:00     ` Jeff King
2016-10-24 17:15       ` Junio C Hamano
2016-10-24 17:27         ` Junio C Hamano
2016-10-24 22:33           ` René Scharfe
2016-10-24 23:53             ` Junio C Hamano
2016-10-25  0:30               ` Jeff King
2016-10-25 18:28                 ` Junio C Hamano
2016-10-25 18:33                   ` Jeff King
2016-10-25 18:37                     ` Junio C Hamano
2016-10-26 17:08                   ` René Scharfe
2016-10-26 17:53                     ` Junio C Hamano

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).