mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06: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:
@@ -2758,14 +2758,17 @@ virFileRemove(const char *path,
|
||||
*/
|
||||
int virDirRead(DIR *dirp, struct dirent **ent, const char *name)
|
||||
{
|
||||
errno = 0;
|
||||
*ent = readdir(dirp); /* exempt from syntax-check */
|
||||
if (!*ent && errno) {
|
||||
if (name)
|
||||
virReportSystemError(errno, _("Unable to read directory '%s'"),
|
||||
name);
|
||||
return -1;
|
||||
}
|
||||
do {
|
||||
errno = 0;
|
||||
*ent = readdir(dirp); /* exempt from syntax-check */
|
||||
if (!*ent && errno) {
|
||||
if (name)
|
||||
virReportSystemError(errno, _("Unable to read directory '%s'"),
|
||||
name);
|
||||
return -1;
|
||||
}
|
||||
} while (*ent && (STREQ((*ent)->d_name, ".") ||
|
||||
STREQ((*ent)->d_name, "..")));
|
||||
return !!*ent;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user