Fix appending of slash when changing working dir

Instead of using an unreliable snprintf, add the slash manually and
terminate the path string.