From 0606c36a73449e76d8f6133253c1eff291ee8c97 Mon Sep 17 00:00:00 2001 From: Andreas Gruenbacher Date: Fri, 8 Jan 2010 14:40:00 +0100 Subject: [PATCH] base85: Make the code more obvious instead of explaining the non-obvious Here is another cleanup ... Signed-off-by: Andreas Gruenbacher Signed-off-by: Junio C Hamano --- base85.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/base85.c b/base85.c index f2b9a24d5..24ddf60eb 100644 --- a/base85.c +++ b/base85.c @@ -57,14 +57,8 @@ int decode_85(char *dst, const char *buffer, int len) de = de85[ch]; if (--de < 0) return error("invalid base85 alphabet %c", ch); - /* - * Detect overflow. The largest - * 5-letter possible is "|NsC0" to - * encode 0xffffffff, and "|NsC" gives - * 0x03030303 at this point (i.e. - * 0xffffffff = 0x03030303 * 85). - */ - if (0x03030303 < acc || + /* Detect overflow. */ + if (0xffffffff / 85 < acc || 0xffffffff - de < (acc *= 85)) return error("invalid base85 sequence %.5s", buffer-5); acc += de; -- 2.26.2