arrow-py / arrow

🏹 Better dates & times for Python
https://arrow.readthedocs.io
Apache License 2.0
8.71k stars 673 forks source link

TypeError when using arrow.get on malformed string #854 #860

Closed Google-Autofuzz closed 3 years ago

Google-Autofuzz commented 4 years ago

I'm getting a TypeError exception when running the following script on the attached output:

import arrow
import sys

with open(sys.argv[1], 'rb') as f:
    data = f.read()

fmtstr, payload = str(data[:24]), str(data[24:])
arrow.get(payload, fmtstr).humanize()

clusterfuzz-testcase-minimized-fuzz_get-5667779260841984.txt

$ python3 test.py  ./clusterfuzz-testcase-minimized-fuzz_get-5667779260841984 
Traceback (most recent call last):
  File "test.py", line 8, in <module>
    arrow.get(payload, fmtstr).humanize()
  File "/home/user/ven/lib/python3.8/site-packages/arrow/api.py", line 21, in get
    return _factory.get(*args, **kwargs)
  File "/home/user/ven/lib/python3.8/site-packages/arrow/factory.py", line 246, in get
    dt = parser.DateTimeParser(locale).parse(
  File "/home/user/ven/lib/python3.8/site-packages/arrow/parser.py", line 244, in parse
    self._parse_token(token, value, parts)
  File "/home/user/ven/lib/python3.8/site-packages/arrow/parser.py", line 386, in _parse_token
    parts["expanded_timestamp"] = int(value)
TypeError: int() argument must be a string, a bytes-like object or a number, not 'NoneType'
$

System Info