diff options
Diffstat (limited to 'packaging/gcc47.patch')
-rw-r--r-- | packaging/gcc47.patch | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/packaging/gcc47.patch b/packaging/gcc47.patch new file mode 100644 index 0000000..542401b --- /dev/null +++ b/packaging/gcc47.patch @@ -0,0 +1,69 @@ +diff --git a/lib/md5.c b/lib/md5.c +index 0770561..e1e6914 100644 +--- a/lib/md5.c ++++ b/lib/md5.c +@@ -82,6 +82,16 @@ md5_read_ctx (ctx, resbuf) + return resbuf; + } + ++static void ++le64_copy (char *dest, uint64_t x) ++{ ++ for (size_t i = 0; i < 8; ++i) ++ { ++ dest[i] = (uint8_t) x; ++ x >>= 8; ++ } ++} ++ + /* Process the remaining bytes in the internal buffer and the usual + prolog according to the standard and write the result to RESBUF. + +@@ -104,10 +114,11 @@ md5_finish_ctx (ctx, resbuf) + pad = bytes >= 56 ? 64 + 56 - bytes : 56 - bytes; + memcpy (&ctx->buffer[bytes], fillbuf, pad); + +- /* Put the 64-bit file length in *bits* at the end of the buffer. */ +- *(md5_uint32 *) &ctx->buffer[bytes + pad] = SWAP (ctx->total[0] << 3); +- *(md5_uint32 *) &ctx->buffer[bytes + pad + 4] = SWAP ((ctx->total[1] << 3) | +- (ctx->total[0] >> 29)); ++ /* Put the 64-bit file length in *bits* at the end of the buffer. */ ++ const uint64_t bit_length = ((ctx->total[0] << 3) ++ + ((uint64_t) ((ctx->total[1] << 3) | ++ (ctx->total[0] >> 29)) << 32)); ++ le64_copy (&ctx->buffer[bytes + pad], bit_length); + + /* Process last bytes. */ + md5_process_block (ctx->buffer, bytes + pad + 8, ctx); +diff --git a/lib/sha1.c b/lib/sha1.c +index 0459cd6..59a9aca 100644 +--- a/lib/sha1.c ++++ b/lib/sha1.c +@@ -83,6 +83,13 @@ sha1_read_ctx (ctx, resbuf) + return resbuf; + } + ++static void ++be64_copy (char *dest, uint64_t x) ++{ ++ for (size_t i = 8; i-- > 0; x >>= 8) ++ dest[i] = (uint8_t) x; ++} ++ + /* Process the remaining bytes in the internal buffer and the usual + prolog according to the standard and write the result to RESBUF. + +@@ -106,9 +113,10 @@ sha1_finish_ctx (ctx, resbuf) + memcpy (&ctx->buffer[bytes], fillbuf, pad); + + /* Put the 64-bit file length in *bits* at the end of the buffer. */ +- *(sha1_uint32 *) &ctx->buffer[bytes + pad] = SWAP ((ctx->total[1] << 3) | +- (ctx->total[0] >> 29)); +- *(sha1_uint32 *) &ctx->buffer[bytes + pad + 4] = SWAP (ctx->total[0] << 3); ++ const uint64_t bit_length = ((ctx->total[0] << 3) ++ + ((uint64_t) ((ctx->total[1] << 3) | ++ (ctx->total[0] >> 29)) << 32)); ++ be64_copy (&ctx->buffer[bytes + pad], bit_length); + + /* Process last bytes. */ + sha1_process_block (ctx->buffer, bytes + pad + 8, ctx); |