diff options
author | Akira TAGOH <akira@tagoh.org> | 2013-06-27 12:30:56 +0900 |
---|---|---|
committer | Akira TAGOH <akira@tagoh.org> | 2013-06-27 12:30:56 +0900 |
commit | 8603e5869505ff06d443b8b22d5357d4caaaac24 (patch) | |
tree | 4f92626eb05a7e5a61b6ef0b4f23ba87c6901191 | |
parent | 9acc14c34a372b54f9075ec3611588298fb2a501 (diff) |
Fix a shift count overflow on 32bit box
-rw-r--r-- | src/fchash.c | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/src/fchash.c b/src/fchash.c index 92585a63..7216beea 100644 --- a/src/fchash.c +++ b/src/fchash.c @@ -190,14 +190,14 @@ FcHashGetSHA256Digest (const FcChar8 *input_strings, } /* set input size at the end */ len *= 8; - block[63 - 0] = len & 0xff; - block[63 - 1] = (len >> 8) & 0xff; - block[63 - 2] = (len >> 16) & 0xff; - block[63 - 3] = (len >> 24) & 0xff; - block[63 - 4] = (len >> 32) & 0xff; - block[63 - 5] = (len >> 40) & 0xff; - block[63 - 6] = (len >> 48) & 0xff; - block[63 - 7] = (len >> 56) & 0xff; + block[63 - 0] = (uint64_t)len & 0xff; + block[63 - 1] = ((uint64_t)len >> 8) & 0xff; + block[63 - 2] = ((uint64_t)len >> 16) & 0xff; + block[63 - 3] = ((uint64_t)len >> 24) & 0xff; + block[63 - 4] = ((uint64_t)len >> 32) & 0xff; + block[63 - 5] = ((uint64_t)len >> 40) & 0xff; + block[63 - 6] = ((uint64_t)len >> 48) & 0xff; + block[63 - 7] = ((uint64_t)len >> 56) & 0xff; FcHashComputeSHA256Digest (ret, block); return FcHashSHA256ToString (ret); @@ -226,7 +226,7 @@ FcHashGetSHA256DigestFromFile (const FcChar8 *filename) { if ((len = fread (ibuf, sizeof (char), 64, fp)) < 64) { - long v; + uint64_t v; /* add a padding */ memset (&ibuf[len], 0, 64 - len); @@ -281,7 +281,7 @@ FcHashGetSHA256DigestFromMemory (const char *fontdata, { if ((length - i) < 64) { - long v; + uint64_t v; size_t n; /* add a padding */ |