Unify handling of getcwd(3) failure and don't rely on buffer contents after failed call

This commit is contained in:
Juhani Krekelä 2021-04-27 12:13:33 +03:00
parent d5db35b861
commit ef5a250670
2 changed files with 3 additions and 2 deletions

View File

@ -735,7 +735,7 @@ ChimeraRequest *lastresort;
if (getcwd( base_url + 5, sizeof(base_url) - 5 ) == NULL) {
perror("getcwd failed");
// Try using just the root of filesystem if we could not get cwd
strcat( base_url, "/" ) ;
strcpy( base_url + 5, "/" ) ;
}
strcat( base_url, "/" ) ;

View File

@ -79,7 +79,8 @@ char **argv;
strcpy( base_url, "file:" ) ;
if (getcwd( base_url + 5, sizeof(base_url) - 5 ) == NULL) {
perror("getcwd failed");
return 1;
// Try using just the root of filesystem if we could not get cwd
strcpy( base_url + 5, "/");
}
strcat( base_url, "/" ) ;