diff options
author | Junio C Hamano <gitster@pobox.com> | 2010-01-18 21:29:47 -0800 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2010-01-18 21:29:47 -0800 |
commit | 011c181cc656c8b3e48882729d1b6238e8c5c537 (patch) | |
tree | 4f4a1c516c474ed6ff0327f852e783d0efa53667 /base85.c | |
parent | ba7e81430a32614982172c7064c01db43f55b4bb (diff) | |
parent | c5034673fd92b6278e6c9d55683770ec01fafc89 (diff) | |
download | git-011c181cc656c8b3e48882729d1b6238e8c5c537.tar.gz |
Merge branch 'maint-1.6.2' into maint-1.6.3
* maint-1.6.2:
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
checkout -m: do not try to fall back to --merge from an unborn branch
branch: die explicitly why when calling "git branch [-a|-r] branchname".
textconv: stop leaking file descriptors
commit: --cleanup is a message option
git count-objects: handle packs bigger than 4G
t7102: make the test fail if one of its check fails
Conflicts:
diff.c
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; } |