use getcwd(3) malloc functionality to handle paths > 1024