Use MAXPATHLEN instead of the hardcoded value 1024.