don't use PATH_MAX

This allows building on Hurd, and fixes path truncation elsewhere.

That silly malloc(*2)/free() dance is required by POSIX, although I know of no system where that code path will be taken: at least glibc, MSVC crt and FreeBSD will malloc() for us.