mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-24 05:25:18 +00:00
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.
This commit is contained in:
parent
a4e6f1eb9c
commit
7cecfba139
@ -2758,6 +2758,7 @@ virFileRemove(const char *path,
|
||||
*/
|
||||
int virDirRead(DIR *dirp, struct dirent **ent, const char *name)
|
||||
{
|
||||
do {
|
||||
errno = 0;
|
||||
*ent = readdir(dirp); /* exempt from syntax-check */
|
||||
if (!*ent && errno) {
|
||||
@ -2766,6 +2767,8 @@ int virDirRead(DIR *dirp, struct dirent **ent, const char *name)
|
||||
name);
|
||||
return -1;
|
||||
}
|
||||
} while (*ent && (STREQ((*ent)->d_name, ".") ||
|
||||
STREQ((*ent)->d_name, "..")));
|
||||
return !!*ent;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user