frida/frida-python — pull request #10 by guillaume-uH57J9 (2014-05-12 23:00:13+00:00)
Title: limit tracer.FileRepository filename length, fix #9

Fix issue #9 - https://github.com/frida/frida-python/issues/9

This limits the handler filename to 42 characters.
Function name (truncated to 32) + "_" (1) + CRC32 (8) + ".js" (3)

I could have checked the PATH again Windows path limit (260) and truncating dynamically based on the actual path length.
But that's a bad idea because the full path may change (ie parent directory is renamed, moved, zip/unzipped), and then the Frida wouldn't be able to find handlers with long names again.
Arguably the simplest & more efficient solution is truncating all to 32 characters, and adding a CRC32 to makes sure we avoid collision.
Of course, the truncating is applied regardless of the actual platform (Windows vs Mac vs Linux) so that things still works when copying handlers on another machine.

Pro:
- Fixes issue #9 on Windows
- Shorter filenames
- Prevent collision thanks to CRC32, even if the function name is truncated

Cons:
- Long function name doesn't appear in full in the filenames