kernel/fs/fd: fcntl(F_DUPFD) should return EINVAL for invalid fds.

fix a failure for test-fcntl.c of gltests.

Change-Id: Ied8effdee2ddd9868bf039dbf74a3057a2541cac
Reviewed-on: https://review.haiku-os.org/c/1331
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
This commit is contained in:
Jérôme Duval 2019-03-29 23:17:17 +01:00 committed by waddlesplash
parent ebc14c9921
commit 532998ed1e

View File

@ -159,6 +159,9 @@ new_fd_etc(struct io_context* context, struct file_descriptor* descriptor,
int fd = -1;
uint32 i;
if (firstIndex < 0 || (uint32)firstIndex >= context->table_size)
return B_BAD_VALUE;
mutex_lock(&context->io_mutex);
for (i = firstIndex; i < context->table_size; i++) {