Skip to content

Conversation

@ZackerySpytz
Copy link
Contributor

@ZackerySpytz ZackerySpytz commented Oct 26, 2019

struct.error is now raised if there is a null character in a struct
format string.

https://bugs.python.org/issue35714

struct.error is now raised if there is a null character in a struct
format string.
Copy link
Member

@mdickinson mdickinson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM


def test_issue35714(self):
# Embedded null characters should not be allowed in format strings.
for s in '\0', '\144\u0064\000xf', 'd\0d', '>ih\0', '=Q\0\0':
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the difference between all these cases? Why they are needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The embedded null is located at different positions of the string.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And why it is handled differently depending on the position?

I would test with '\0', '2\0i' and b'\0'.

@csabella csabella requested a review from serhiy-storchaka May 23, 2020 18:00
@serhiy-storchaka serhiy-storchaka added needs backport to 3.6 type-bug An unexpected behavior, bug, or error labels May 25, 2020
@serhiy-storchaka serhiy-storchaka merged commit 3f59b55 into python:master May 25, 2020
@miss-islington
Copy link
Contributor

Thanks @ZackerySpytz for the PR, and @serhiy-storchaka for merging it 🌮🎉.. I'm working now to backport this PR to: 3.6, 3.7, 3.8, 3.9.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request May 25, 2020
…16928)

struct.error is now raised if there is a null character in a struct
format string.
(cherry picked from commit 3f59b55)

Co-authored-by: Zackery Spytz <zspytz@gmail.com>
@bedevere-bot
Copy link

GH-20373 is a backport of this pull request to the 3.9 branch.

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request May 25, 2020
…16928)

struct.error is now raised if there is a null character in a struct
format string.
(cherry picked from commit 3f59b55)

Co-authored-by: Zackery Spytz <zspytz@gmail.com>
@bedevere-bot
Copy link

GH-20374 is a backport of this pull request to the 3.8 branch.

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request May 25, 2020
…16928)

struct.error is now raised if there is a null character in a struct
format string.
(cherry picked from commit 3f59b55)

Co-authored-by: Zackery Spytz <zspytz@gmail.com>
@bedevere-bot
Copy link

GH-20375 is a backport of this pull request to the 3.7 branch.

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request May 25, 2020
…16928)

struct.error is now raised if there is a null character in a struct
format string.
(cherry picked from commit 3f59b55)

Co-authored-by: Zackery Spytz <zspytz@gmail.com>
@bedevere-bot
Copy link

GH-20376 is a backport of this pull request to the 3.6 branch.

miss-islington added a commit that referenced this pull request May 26, 2020
struct.error is now raised if there is a null character in a struct
format string.
(cherry picked from commit 3f59b55)

Co-authored-by: Zackery Spytz <zspytz@gmail.com>
ZackerySpytz added a commit to ZackerySpytz/cpython that referenced this pull request May 26, 2020
…honGH-16928)

struct.error is now raised if there is a null character in a struct
format string.
(cherry picked from commit 3f59b55)

Co-authored-by: Zackery Spytz <zspytz@gmail.com>
serhiy-storchaka pushed a commit that referenced this pull request May 26, 2020
…16928) (GH-20419)

struct.error is now raised if there is a null character in a struct
format string.
(cherry picked from commit 3f59b55)
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request May 26, 2020
…honGH-16928) (pythonGH-20419)

struct.error is now raised if there is a null character in a struct
format string.
(cherry picked from commit 3f59b55)
(cherry picked from commit 5ff5edf)

Co-authored-by: Zackery Spytz <zspytz@gmail.com>
miss-islington added a commit that referenced this pull request May 26, 2020
…16928) (GH-20419)

struct.error is now raised if there is a null character in a struct
format string.
(cherry picked from commit 3f59b55)
(cherry picked from commit 5ff5edf)

Co-authored-by: Zackery Spytz <zspytz@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type-bug An unexpected behavior, bug, or error

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants