Code

Documentation: receive.denyCurrentBranch defaults to 'refuse'
[git.git] / base85.c
index f2b9a24d5ec9f470f77a3d2396d60c285108c8e9..e459feebbf90c6557dbf3ff913f83a57a8afb210 100644 (file)
--- 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;
@@ -89,7 +83,7 @@ void encode_85(char *buf, const unsigned char *data, int bytes)
                unsigned acc = 0;
                int cnt;
                for (cnt = 24; cnt >= 0; cnt -= 8) {
-                       int ch = *data++;
+                       unsigned ch = *data++;
                        acc |= ch << cnt;
                        if (--bytes == 0)
                                break;