Skip to content

gh-153605: Fix gettext.GNUTranslations struct.error on a malformed .mo file#153606

Open
tonghuaroot wants to merge 1 commit into
python:mainfrom
tonghuaroot:gettext-mo-struct-error
Open

gh-153605: Fix gettext.GNUTranslations struct.error on a malformed .mo file#153606
tonghuaroot wants to merge 1 commit into
python:mainfrom
tonghuaroot:gettext-mo-struct-error

Conversation

@tonghuaroot

Copy link
Copy Markdown
Contributor

gettext.GNUTranslations unpacked the .mo header and per-entry seek tables
with struct.unpack without first checking the file was long enough, so a
truncated file or one whose seek tables point past the end raised a raw
struct.error instead of the OSError the module already raises for other
malformed input. Validate the lengths and raise OSError instead.

…med .mo file

GNUTranslations._parse unpacked the .mo header and seek tables without
checking the file was long enough, so a truncated file or one whose seek
tables point past the end leaked a struct.error instead of the OSError the
module raises for other malformed input. Validate the lengths first.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant