diff options
| author | Junio C Hamano <gitster@pobox.com> | 2010-01-10 00:52:04 -0800 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2010-01-10 00:52:04 -0800 |
| commit | 83b10ca25fd49d25561fd6344bd8e40b8987f50a (patch) | |
| tree | 8a57673412f8a5d9ebc1ba59c2101119e8a5bf08 /base85.c | |
| parent | 15515b73716a6ead5a5a348a7d04cc7d73c74bff (diff) | |
| parent | 8fb5d44a47dd3657c8be0de5dcf220935b04e98e (diff) | |
| download | git-83b10ca25fd49d25561fd6344bd8e40b8987f50a.tar.gz | |
Merge branch 'maint'
* maint:
base85: Make the code more obvious instead of explaining the non-obvious
base85: encode_85() does not use the decode table
base85 debug code: Fix length byte calculation
Documentation: tiny git config manual tweaks
Documentation: git gc packs refs by default now
checkout -m: do not try to fall back to --merge from an unborn branch
Diffstat (limited to 'base85.c')
| -rw-r--r-- | base85.c | 14 |
1 files changed, 3 insertions, 11 deletions
@@ -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; @@ -84,8 +78,6 @@ int decode_85(char *dst, const char *buffer, int len) void encode_85(char *buf, const unsigned char *data, int bytes) { - prep_base85(); - say("encode 85"); while (bytes) { unsigned acc = 0; @@ -118,7 +110,7 @@ int main(int ac, char **av) int len = strlen(av[2]); encode_85(buf, av[2], len); if (len <= 26) len = len + 'A' - 1; - else len = len + 'a' - 26 + 1; + else len = len + 'a' - 26 - 1; printf("encoded: %c%s\n", len, buf); return 0; } |
