Fix FTBFS on GNU/Hurd

Currently appstream-glib FTBFS on GNU/Hurd due to usage of PATH_MAX,
which is not defined. The attached patch solves this problem by
dynamically allocating strings of required length, and free them after
usage if needed.

Many thanks to Svante Signell <svante.signell@gmail.com> for the patch!

Reference: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=766333
(patch modified to apply on the current Git master)