Make sure cwd is always NULL-terminated. It always it, but a further check doesn't hurt