Skip to content
Merged
Show file tree
Hide file tree
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
4 changes: 3 additions & 1 deletion src/oscompat.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ static inline bool path_is_absolute(const char *path)
#ifndef _WIN32
return path[0] == '/';
#else
return (isalpha(path[0]) && path[1] == ':') ||
if (path[0] == '\0')
return false;
return (isalpha((unsigned char)path[0]) && path[1] == ':') ||
(path[0] == '\\' && path[1] == '\\');
#endif
}
Expand Down
8 changes: 7 additions & 1 deletion tests/test_oscompat.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,13 @@ static void rmtree(const char *path)
if (!strcmp(ent->d_name, ".") || !strcmp(ent->d_name, ".."))
continue;

snprintf(child, sizeof(child), "%s/%s", path, ent->d_name);
if (snprintf(child, sizeof(child), "%s/%s", path,
ent->d_name) >= (int)sizeof(child)) {
fprintf(stderr,
"skipping overly-long path %s/%s\n",
path, ent->d_name);
continue;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we warn here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right call, I've added the warning there

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

overly-long

__func__ is generally discouraged in the kernel coding style. I think we should follow. Feel free to merge with that.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed, thanks!

}
if (stat(child, &st) == 0 && S_ISDIR(st.st_mode))
rmtree(child);
else
Expand Down
Loading