New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
plistlib crashes too easily on bad files #40507
Comments
Plistlib doesn't do much error checking, and it can crash on bad The problem I ran into was a dangling <key>foo</key>. After this I was about to fix this when I noticed that there's lots of problems |
The attached patch fixes crashes on bad input. The patch implements validation for dict and array elements as well as some resource cleanup. The tests are included as well. |
One review comment: the patch adds a new exception class that is used for the errors that are now additionally detected. Elsewhere plistlib uses non-specific exception classes like ValueError. If starting from scratch, it might be better to consistently use a specific exception class but that would create incompatibilities if changed now. I don't see a compelling need to add one now just for these errors. (But, if kept, it should be added to the docs.) Otherwise, looks good to me. Thanks for taking this on! |
I've replaced plistlib.InvalidPlistError with ValueError |
LGTM. |
See also reopened dependency bpo-775321. |
New changeset a2688e252204 by Ned Deily in branch '3.1': New changeset f555d959a5d7 by Ned Deily in branch '3.2': New changeset d0bc18a50bd1 by Ned Deily in branch 'default': |
Thank you for the patch and tests! Applied in 3.1 (for 3.1.4), 3.2 (for 3.2.1), and 3.3. (The 2.x version of plistlib differs somewhat from the 3.x version so the patch would need some rework and testing for 2.7; that is probably not worth the effort at this point.) |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: