allocate `history_path` dynamically

`PATH_MAX` doesn't have to be defined and if it is, then its value is
usually incorrect (possible buffer overflow).
Use `malloc` and `snprintf` instead to prevent this.

https://www.gnu.org/software/hurd/community/gsoc/project_ideas/maxpath.html