Use strrchr() insteaad of rindex().
[tinc] / src / raw_socket /
drwxr-xr-x   ..
-rw-r--r-- 3391 device.c