1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

sys/vfs: Check suggested fd is valid

Avoids out of bounds array access on _vfs_open_files if vfs_bind is
called with an invalid (positive) fd number
This commit is contained in:
Joakim Nohlgård 2018-02-12 08:45:19 +01:00
parent 368818aa23
commit 490e7c87e0

View File

@ -871,10 +871,10 @@ static inline int _allocate_fd(int fd)
break;
}
}
if (fd >= VFS_MAX_OPEN_FILES) {
/* The _vfs_open_files array is full */
return -ENFILE;
}
}
if (fd >= VFS_MAX_OPEN_FILES) {
/* The _vfs_open_files array is full */
return -ENFILE;
}
else if (_vfs_open_files[fd].pid != KERNEL_PID_UNDEF) {
/* The desired fd is already in use */