Closed guillaume-uH57J9 closed 10 years ago
Great catch! I guess one way would be to add a to_filepath()
function that takes care of the truncation of the final path. So if len(path) > 260
then trim off 8 + len(path) - 260
characters at the end of the filename (before the extension), and put a hex-encoded CRC32 there. Feel free to open a PR if you have time (if not I can have a look at it before the next release).
Thanks!
Thanks.
The PR will arrive soon.
I believe doing the truncation as a function of len(path) is actually a bad idea. Even if the function name should have a constant length, the complete path length may change (for instance the parent directory is renamed, moved, zip/unzipped...). So frida will be unable to find the scripts in all these situation, which would be really annoying. Or it would have to verify many tests to find the correct length, and we don't want to slow things down with unecessary I/O.
So, my PR will probably include a fixed limit on length + CRC32 for a more deterministic result.
Guillaume
2014-05-12 20:41 GMT+02:00 Ole André Vadla Ravnås notifications@github.com :
Great catch! I guess one way would be to add a to_filepath() function that takes care of the truncation of the final path. So if len(path) > 260then trim off 8
- len(path) - 260 characters at the end of the filename (before the extension), and put a hex-encoded CRC32 there. Feel free to open a PR if you have time (if not I can have a look at it before the next release).
Thanks!
— Reply to this email directly or view it on GitHubhttps://github.com/frida/frida-python/issues/9#issuecomment-42871012 .
Ahh yes, that's a very good point! Fixed length is definitely the way to go then. Thanks!
The affects Frida 1.4.0, specifically python file frida/tracer.py
On Windows, Frida crashes with a unhandled file not found exception because of the Windows API path length limitation (260 characters). For details see Maximum Path Length Limitation at http://msdn.microsoft.com/en-us/library/windows/desktop/aa365247%28v=vs.85%29.aspx
This occurs very easily with Java methods that have a very long mangled name (blah_method_blah_type_pointer_paramater_typebisparameterbis...).
See below an extract of a modified tracer.py that solves this issue by taking only 32 characters for the function name in case the total path length is longer then 260.
A proper solution would be always limiting the function name to 32 characters to obtain more consistent and predictable file names. Then append a CRC32 of the function name to make sure there's no collision. There is a real risk of collision if the function names are truncated, especially with function overloading, so you should really consider adding a unique suffix like CRC32.