ddvk / remarkable2-framebuffer

remarkable2 framebuffer reversing
MIT License
279 stars 22 forks source link

Fix segfault with relative argv[0] in client #40

Closed matteodelabre closed 3 years ago

matteodelabre commented 3 years ago

Running LD_PRELOAD=/path/to/librm2fb_client.so.1.0.0 xochitl currently results in a segfault because swtfb::locate_signature is called with a relative binary path, and therefore fopen fails in swtfb::read_file.

This patch replaces the use of argv[0] with reading /proc/self/exe which always return an absolute path to the current executable.

It also adds some error checking to swtfb::read_file so that we get a nicer error message instead of a segfault, should a similar bug happen again.

raisjn commented 3 years ago

looks reasonable, thanks for fixing this! just need to test (later today, probably) before merging (unless someone beats me to it)

raisjn commented 3 years ago

tested that this works for client.so by invoking LD_PRELOAD=/home/root/rm2fb/librm2fb_client.so.1.0.0 fbink hello world and seeing hello world appear in top left.