]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
py:common: normalise_int32 checks bit size
authorDouglas Bagnall <douglas.bagnall@catalyst.net.nz>
Tue, 29 Jul 2025 23:57:02 +0000 (11:57 +1200)
committerDouglas Bagnall <dbagnall@samba.org>
Thu, 7 Aug 2025 23:28:33 +0000 (23:28 +0000)
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
python/samba/common.py
selftest/knownfail.d/python-common [deleted file]

index eafc4175b4cab74363a9f8cb4442eb47632db66f..f11cf383807762bb005b1fee6d98a00cf1259989 100644 (file)
@@ -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 (file)
index 3d73084..0000000
+++ /dev/null
@@ -1 +0,0 @@
-samba.tests.common.samba.tests.common.CommonTests.test_normalise_int32