From strncat() man page: "If src contains n or more characters, strncat() writes n+1 characters to dest (n from src plus the terminating null byte). Therefore, the size of dest must be at least strlen(dest)+n+1."
Therefore it is necessary to set the n parameter of strncat to maxlen-1.
Unix: Fixing compiler warnings
From strncat() man page: "If src contains n or more characters, strncat()
writes n+1 characters to dest (n from src plus the terminating null
byte). Therefore, the size of dest must be at least strlen(dest)+n+1."
Therefore it is necessary to set the n parameter of strncat to maxlen-1.
Also checking return value of getcwd().