Skip to content

Commit

Permalink
base85: Make the code more obvious instead of explaining the non-obvious
Browse files Browse the repository at this point in the history
Here is another cleanup ...

Signed-off-by: Andreas Gruenbacher <[email protected]>
Signed-off-by: Junio C Hamano <[email protected]>
  • Loading branch information
Andreas Gruenbacher authored and gitster committed Jan 10, 2010
1 parent b0bec51 commit 0606c36
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions base85.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 0606c36

Please sign in to comment.