Summary: | sys-apps/portage: test failure with dev-libs/openssl-3 | ||
---|---|---|---|
Product: | Portage Development | Reporter: | Sam James <sam> |
Component: | Core | Assignee: | Portage team <dev-portage> |
Status: | RESOLVED FIXED | ||
Severity: | normal | CC: | mgorny, python, t |
Priority: | Normal | ||
Version: | unspecified | ||
Hardware: | All | ||
OS: | Linux | ||
See Also: |
https://bugs.gentoo.org/show_bug.cgi?id=844148 https://bugs.gentoo.org/show_bug.cgi?id=885909 |
||
Whiteboard: | |||
Package list: | Runtime testing required: | --- | |
Bug Depends on: | 837899 | ||
Bug Blocks: | 797325 | ||
Attachments: | build.log |
Description
Sam James
2022-05-19 04:17:26 UTC
(Using local overlay for portage ebuild just for libselinux not supporting py3.11 yet, shouldn't be relevant here.) As discussed on IRC, my guess is that the code path with the local whirlpool fallback hasn't been tested in years (because hashlib supplied one prior to openssl-3.x). I think I managed to reproduce: * Check out tag portage-3.0.30 * apply the patch listed at the bottom * run './runtests lib/portage/tests/util/test_checksum.py' and you should get the following error: ====================================================================== ERROR: test_whirlpool (portage.tests.util.test_checksum.ChecksumTestCase) ---------------------------------------------------------------------- Traceback (most recent call last): File "/home/tj/sources/gentoo/portage/lib/portage/tests/__init__.py", line 248, in run testMethod() File "/home/tj/sources/gentoo/portage/lib/portage/tests/util/test_checksum.py", line 62, in test_whirlpool checksum_str(b"", "WHIRLPOOL"), File "/home/tj/sources/gentoo/portage/lib/portage/checksum.py", line 643, in checksum_str return hashfunc_map[hashname].checksum_str(data) File "/home/tj/sources/gentoo/portage/lib/portage/checksum.py", line 76, in checksum_str checksum.update(data) File "/home/tj/sources/gentoo/portage/lib/portage/util/whirlpool.py", line 49, in update WhirlpoolAdd(arg, len(arg) * 8, self.ctx) File "/home/tj/sources/gentoo/portage/lib/portage/util/whirlpool.py", line 2223, in WhirlpoolAdd b = (source[sourcePos] << sourceGap) & 0xFF IndexError: index out of range (once for each python version installed, I think) From d90fdd3beb2cb6ba33fdbed5d5e3b4a01a59f4ae Mon Sep 17 00:00:00 2001 From: Thomas Bracht Laumann Jespersen <t@laumann.xyz> Date: Thu, 19 May 2022 10:56:02 +0200 Subject: [PATCH] Force used of bundled whirlpool --- lib/portage/checksum.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/portage/checksum.py b/lib/portage/checksum.py index c19a50df9..d0f294b36 100644 --- a/lib/portage/checksum.py +++ b/lib/portage/checksum.py @@ -110,7 +110,7 @@ _generate_hash_function("SHA256", hashlib.sha256, origin="hashlib") _generate_hash_function("SHA512", hashlib.sha512, origin="hashlib") for local_name, hash_name in ( ("RMD160", "ripemd160"), - ("WHIRLPOOL", "whirlpool"), + #("WHIRLPOOL", "whirlpool"), # available since Python 3.6 ("BLAKE2B", "blake2b"), ("BLAKE2S", "blake2s"), @@ -270,7 +270,7 @@ if "RMD160" not in hashfunc_map or "WHIRLPOOL" not in hashfunc_map: for local_name, hash_name in ( ("RMD160", "RIPEMD160"), - ("WHIRLPOOL", "WHIRLPOOL"), + #("WHIRLPOOL", "WHIRLPOOL"), ): if local_name not in hashfunc_map and hasattr( mhash, "MHASH_%s" % hash_name -- 2.35.1 The bug has been closed via the following commit(s): https://gitweb.gentoo.org/proj/portage.git/commit/?id=1f33f97b9e9c132d77d586d10bfe6ba0d3123050 commit 1f33f97b9e9c132d77d586d10bfe6ba0d3123050 Author: Thomas Bracht Laumann Jespersen <t@laumann.xyz> AuthorDate: 2022-05-19 09:50:05 +0000 Commit: Michał Górny <mgorny@gentoo.org> CommitDate: 2022-05-21 10:11:50 +0000 lib/portage/util: fix bundled whirlpool on empty bytestring input The WhirlpoolAdd function did not consider zero-length input, so calls to update(b'') would produce out-of-bounds errors. This was not covered by any tests, because the constructor implicitly skipped the call to update on zero-length input. Add check for zero-length input to WhirlpoolAdd, and have the Whirlpool constructor skip calling update() only if arg is None. Closes: https://bugs.gentoo.org/846389 Signed-off-by: Thomas Bracht Laumann Jespersen <t@laumann.xyz> Closes: https://github.com/gentoo/portage/pull/832 Signed-off-by: Michał Górny <mgorny@gentoo.org> lib/portage/util/whirlpool.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) The bug has been referenced in the following commit(s): https://gitweb.gentoo.org/proj/portage.git/commit/?id=b0e43d6bc73cb63642404e661b073d6183fb9aa8 commit b0e43d6bc73cb63642404e661b073d6183fb9aa8 Author: Sam James <sam@gentoo.org> AuthorDate: 2023-03-20 03:37:26 +0000 Commit: Sam James <sam@gentoo.org> CommitDate: 2023-03-21 02:30:24 +0000 checksum: add further comments on existing fallback logic for RIPEMD/WHIRLPOOL Bug: https://github.com/python/cpython/issues/91257 Bug: https://github.com/python/cpython/issues/92876 Bug: https://bugs.gentoo.org/846389 Signed-off-by: Sam James <sam@gentoo.org> lib/portage/checksum.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) |