mirror of
https://github.com/amadvance/snapraid.git
synced 2026-10-26 10:51:54 -04:00
Check dirfd result before using it
This commit is contained in:
parent
c180015fdc
commit
ad2a36f2c7
1 changed files with 7 additions and 1 deletions
|
|
@ -506,12 +506,18 @@ static int devuuid_dev(uint64_t device, char* uuid, size_t uuid_size)
|
|||
return -1;
|
||||
}
|
||||
|
||||
int dir_fd = dirfd(d);
|
||||
if (dir_fd == -1) {
|
||||
log_tag("uuid:by-uuid:%u:%u: dirfd(/dev/disk/by-uuid) failed, %s\n", major(device), minor(device), strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
while ((dd = readdir(d)) != 0) {
|
||||
/* skip "." and ".." files, UUIDs never start with '.' */
|
||||
if (dd->d_name[0] == '.')
|
||||
continue;
|
||||
|
||||
ret = fstatat(dirfd(d), dd->d_name, &st, 0);
|
||||
ret = fstatat(dir_fd, dd->d_name, &st, 0);
|
||||
if (ret != 0) {
|
||||
log_tag("uuid:by-uuid:%u:%u: fstatat(%s) failed, %s\n", major(device), minor(device), dd->d_name, strerror(errno));
|
||||
/* generic error, ignore and continue the search */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue