unnecessary check

This commit is contained in:
diamant3
2024-06-15 15:06:19 +08:00
parent 9f22620808
commit 14f61b44d0

View File

@@ -1193,32 +1193,6 @@ char *realpath(const char *path, char *resolved_path)
return NULL;
}
/* check the length of every component of path arg */
char component[NAME_MAX + 1];
const char *start = path;
const char *end;
while (*start != '\0') {
end = start;
// find the next '/'
while (*end != '/' && *end != '\0') { end++; }
// compute path component length
size_t len = end - start;
if (len > NAME_MAX) {
errno = ENAMETOOLONG;
return NULL;
}
// copy start to component buffer
memcpy(component, start, len);
component[len] = '\0';
// move to the next component
if (*end == '/') { start = end + 1; }
else { start = end; }
}
/* check if file or directory exist */
struct stat st;
if (stat(path, &st) == 0) {