Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

TypeError: '<' not supported between instances of 'NoneType' and 'int' raised during call to email.message_from_file #134151

Copy link
Copy link
Open
@gabe-sherman

Description

@gabe-sherman
Issue body actions

Bug report

Bug description:

During fuzzing of Python standard libraries, the following code snippet causes a TypeError with the following message: TypeError: '<' not supported between instances of 'NoneType' and 'int'. This occurs in the decode_params function at line 419 in email/utils.py.

import sys
import io
import email
d =  io.StringIO(open(sys.argv[1], "r").read())
email.message_from_file(d)

POC File:

https://github.com/FuturesLab/POC/blob/main/py-email/poc-02

Exception Trace

Traceback (most recent call last):
  File "rep.py", line 5, in <module>
    email.message_from_file(d)
  File "/usr/lib/python3.12/email/__init__.py", line 53, in message_from_file
    return Parser(*args, **kws).parse(fp)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/email/parser.py", line 54, in parse
    return feedparser.close()
           ^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/email/feedparser.py", line 185, in close
    self._call_parse()
  File "/usr/lib/python3.12/email/feedparser.py", line 178, in _call_parse
    self._parse()
  File "/usr/lib/python3.12/email/feedparser.py", line 304, in _parsegen
    boundary = self._cur.get_boundary()
               ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/email/message.py", line 861, in get_boundary
    boundary = self.get_param('boundary', missing)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/email/message.py", line 725, in get_param
    for k, v in self._get_params_preserve(failobj, header):
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/email/message.py", line 674, in _get_params_preserve
    params = utils.decode_params(params)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/email/utils.py", line 419, in decode_params
    continuations.sort()
TypeError: '<' not supported between instances of 'NoneType' and 'int'

CPython versions tested on:

3.12, 3.11, 3.10, 3.9

Operating systems tested on:

Linux

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlibPython modules in the Lib dirPython modules in the Lib dirtopic-emailtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.