Revert to the state after d7796855b8 and use the underlying buffer directly. I was still under the impression that was unsafe, so I did a drive-by fix, which this commit reverts.
d7796855b8
PATH_MAX