提交 7cecfba1 编写于 作者: J Ján Tomko

Skip '.' and '..' in virDirRead

All of the callers either skip these explicitly, skip all entries
starting with a dot or match the entry name against stricter patterns.
上级 a4e6f1eb
...@@ -2758,14 +2758,17 @@ virFileRemove(const char *path, ...@@ -2758,14 +2758,17 @@ virFileRemove(const char *path,
*/ */
int virDirRead(DIR *dirp, struct dirent **ent, const char *name) int virDirRead(DIR *dirp, struct dirent **ent, const char *name)
{ {
errno = 0; do {
*ent = readdir(dirp); /* exempt from syntax-check */ errno = 0;
if (!*ent && errno) { *ent = readdir(dirp); /* exempt from syntax-check */
if (name) if (!*ent && errno) {
virReportSystemError(errno, _("Unable to read directory '%s'"), if (name)
name); virReportSystemError(errno, _("Unable to read directory '%s'"),
return -1; name);
} return -1;
}
} while (*ent && (STREQ((*ent)->d_name, ".") ||
STREQ((*ent)->d_name, "..")));
return !!*ent; return !!*ent;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册