mirror of
https://github.com/samba-team/samba.git
synced 2025-12-19 12:23:49 +03:00
py:common: normalise_int32 checks bit size
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
This commit is contained in:
committed by
Douglas Bagnall
parent
8f733c1262
commit
a579efadaa
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user