Stop using MAXPATHLEN everywhere, explicitely define MAX_OUTPUT_LEN.