lockfile: fix buffer overflow in path handling