Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

ValueError: embedded null character inemail.message_from_file #134156

Closed as not planned
Labels
pendingThe issue will be closed if no feedback is providedstdlibPython modules in the Lib dirtopic-emailtype-bugAn unexpected behavior, bug, or error
@gabe-sherman

Description

@gabe-sherman

Bug report

Bug description:

During fuzzing of Python standard libraries, the following code snippet causes aValueError with the following message:ValueError: embedded null character. This occurs in thecollapse_rfc2231_value function at line 455 inemail/utils.py.

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

POC File

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

Exception Trace

Traceback (most recent call last):  File "rep.py", line 5, in <module>    message_from_fileval1 = 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 865, in get_boundary    return utils.collapse_rfc2231_value(boundary).rstrip()           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  File "/usr/lib/python3.12/email/utils.py", line 455, in collapse_rfc2231_value    return str(rawbytes, charset, errors)           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ValueError: embedded null character

CPython versions tested on:

3.12, 3.11, 3.10, 3.9

Operating systems tested on:

Linux

Metadata

Metadata

Assignees

No one assigned

    Labels

    pendingThe issue will be closed if no feedback is providedstdlibPython modules in the Lib dirtopic-emailtype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp