Limit toDatetime to 32-bit integer

This commit is contained in:
JonnyWong16 2021-05-10 16:11:16 -07:00
parent 158c5f5633
commit 975a9eb3a2
No known key found for this signature in database
GPG key ID: B1F1F9807184697A

View file

@ -200,9 +200,8 @@ def toDatetime(value, format=None):
else:
# https://bugs.python.org/issue30684
# And platform support for before epoch seems to be flaky.
# TODO check for others errors too.
if int(value) <= 0:
value = 86400
# Also limit to max 32-bit integer
value = min(max(int(value), 86400), 2**31 - 1)
value = datetime.fromtimestamp(int(value))
return value