Hi James, Thanks for the report.
James Ring writes: > Confirmed that with the offending patch, md5.c produces incorrect > digests for known input/output pairs. We should roll it back. > > Also I couldn't reproduce (with gcc 7.2.0) the compiler warning that > the original change was supposed to fix. Hmm, neither can I. In neither the debian-8-mini nor debian-9-mini CI environments. But you can still see it in the CI logs for the last pipeline that ran before the offending commit. https://gitlab.com/sane-project/backends/pipelines/4150861 Only the fedora-24-clang log doesn't have it. > On Tue, Jan 2, 2018 at 9:57 AM, James Ring <s...@jdns.org> wrote: >> [...snip...] >> >> Reverting that commit restores the functionality. I haven't figured >> out what the problem is from a cursory inspection of the code, I'll >> continue staring at it. I was about to revert the commit but looking at it now I'm wondering what I was thinking when I committed that :-( Changing the pointer type to something of a different size *obviously* screws up the array indexing! I've cooked up a fix for that (based on e895ee55). Could you give the attached patch a try? Hope this helps, -- Olaf Meeuwissen, LPIC-2 FSF Associate Member since 2004-01-27 GnuPG key: F84A2DD9/B3C0 2F47 EA19 64F4 9F13 F43E B8A4 A88A F84A 2DD9 Support Free Software https://my.fsf.org/donate Join the Free Software Foundation https://my.fsf.org/join
>From 3651d8c6cd943a1d046e2625bb7bf2eca6f91c42 Mon Sep 17 00:00:00 2001 From: Olaf Meeuwissen <paddy-h...@member.fsf.org> Date: Wed, 3 Jan 2018 16:13:16 +0900 Subject: [PATCH] Fix array indexing. This fixes a glaring oversight in 39ceeae6. Thanks to James Ring for reporting this. --- lib/md5.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/md5.c b/lib/md5.c index 72b36f35..923a17c7 100644 --- a/lib/md5.c +++ b/lib/md5.c @@ -123,6 +123,7 @@ md5_finish_ctx (struct md5_ctx *ctx, void *resbuf) /* Take yet unprocessed bytes into account. */ md5_uint32 bytes = ctx->buflen; size_t pad; + size_t offset; /* Now count remaining bytes. */ ctx->total[0] += bytes; @@ -133,9 +134,11 @@ md5_finish_ctx (struct md5_ctx *ctx, void *resbuf) 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)); + offset = (bytes + pad) / sizeof (md5_uint32); + ((md5_uint32 *) ctx->buffer)[offset] = SWAP (ctx->total[0] << 3); + offset = (bytes + pad + 4) / sizeof (md5_uint32); + ((md5_uint32 *) ctx->buffer)[offset] = SWAP ((ctx->total[1] << 3) | + (ctx->total[0] >> 29)); /* Process last bytes. */ md5_process_block (ctx->buffer, bytes + pad + 8, ctx); -- 2.11.0
-- sane-devel mailing list: sane-devel@lists.alioth.debian.org http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/sane-devel Unsubscribe: Send mail with subject "unsubscribe your_password" to sane-devel-requ...@lists.alioth.debian.org