From: Douglas Bagnall Date: Tue, 29 Jul 2025 23:57:02 +0000 (+1200) Subject: py:common: normalise_int32 checks bit size X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a579efadaadbd12f1debb70e4383db87cf20c86a;p=thirdparty%2Fsamba.git py:common: normalise_int32 checks bit size Signed-off-by: Douglas Bagnall Reviewed-by: Gary Lockyer --- diff --git a/python/samba/common.py b/python/samba/common.py index eafc4175b4c..f11cf383807 100644 --- a/python/samba/common.py +++ b/python/samba/common.py @@ -65,7 +65,10 @@ def confirm(msg, forced=False, allow_all=False): def normalise_int32(ivalue): """normalise a ldap integer to signed 32 bit""" - if int(ivalue) & 0x80000000 and int(ivalue) > 0: + ivalue = int(ivalue) + if ivalue > 0xffffffff or ivalue < -0x80000000: + raise ValueError(f"{ivalue} (0x{ivalue:x}) does not fit in 32 bits.") + if ivalue >= 0x80000000: return str(int(ivalue) - 0x100000000) return str(ivalue) diff --git a/selftest/knownfail.d/python-common b/selftest/knownfail.d/python-common deleted file mode 100644 index 3d73084472d..00000000000 --- a/selftest/knownfail.d/python-common +++ /dev/null @@ -1 +0,0 @@ -samba.tests.common.samba.tests.common.CommonTests.test_normalise_int32