Skip to content

Conversation

@vthib
Copy link
Contributor

@vthib vthib commented Mar 9, 2025

When providing a file to the compile function, the PyObject_AsFileDescriptor function is used, which is safe to use on any object type: if the object is not a file, -1 is returned.

However, this value was passed straight to a call to dup() without checking for its validity. This isn't much of an issue on unix where the dup call will simply fail as well and return -1, but it is very much an issue on windows where passing an invalid fd to dup will invoke the invalid parameter handler, which isn't set, so it will simply terminate the program.

In other words, passing anything but a file to the file parameter of the compile function will make the program crash on Windows.

When providing a file to the compile function, the PyObject_AsFileDescriptor
function is used, which is safe to use on any object type: if the object is
not a file, -1 is returned.

However, this value was passed straight to a call to dup() without checking
for its validity. This isn't much of an issue on unix where the dup call will
simply fail as well and return -1, but it is very much an issue on windows
where passing an invalid fd to dup will invoke the invalid parameter handler,
which isn't set, so it will simply terminate the program.

In other words, passing anything but a file to the file parameter
of the compile function will make the program crash on Windows.
@plusvic plusvic merged commit df256bc into VirusTotal:master Mar 12, 2025
2 of 7 checks passed
@vthib vthib deleted the fix-windows-crash-invalid-file branch March 24, 2025 23:54
plusvic added a commit that referenced this pull request Apr 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants