Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 14 additions & 7 deletions utils/utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <errno.h>

#include "utils/messages.h"
#include "utils/dirent.h"
Expand Down Expand Up @@ -472,14 +473,20 @@ int uname(struct utsname *buf) {

char *realpath(const char *path, char *resolved_path)
{
char *ret;
if (resolved_path == NULL) {
ret=strdup(path);
} else {
ret = resolved_path;
strcpy(resolved_path, path);
if (path == NULL) {
errno = EINVAL;
return NULL;
}
return ret;

/* Without a system realpath(), we cannot safely copy into an unknown-sized
* caller buffer. Provide only the allocating form.
*/
if (resolved_path != NULL) {
errno = ENAMETOOLONG;
return NULL;
}

return strdup(path);
}

#endif
Expand Down