You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The "magic" module has an issue that may cause the type() and mime_type() functions to return wrong results. The issue is caused by the caching mechanism, which holds a pointer to a buffer that becomes invalid after the libmagic API is called by a second time.
In the example above, the first time that type() is called it returns a value that gets cached internally by saving the pointer returned by the magic_buffer function, which is part of the libmagic API. This buffer is valid only until the call to mime_type(). When type() is called by the second time the module doesn't call magic_buffer again, it uses the previously cached pointer which was already invalid. This causes that the second call to type() may return gibberish or even crash.
The text was updated successfully, but these errors were encountered:
plusvic
changed the title
Issue in "magic" module can lead to bad results.
Issue in "magic" module can lead to bad results or crash
Mar 17, 2022
The "magic" module has an issue that may cause the
type()
andmime_type()
functions to return wrong results. The issue is caused by the caching mechanism, which holds a pointer to a buffer that becomes invalid after thelibmagic
API is called by a second time.In the example above, the first time that
type()
is called it returns a value that gets cached internally by saving the pointer returned by themagic_buffer
function, which is part of thelibmagic
API. This buffer is valid only until the call tomime_type()
. Whentype()
is called by the second time the module doesn't callmagic_buffer
again, it uses the previously cached pointer which was already invalid. This causes that the second call totype()
may return gibberish or even crash.The text was updated successfully, but these errors were encountered: