-
Notifications
You must be signed in to change notification settings - Fork 76
Open
Description
In file.c, you write file_get_descriptor as
static struct file_descriptor* file_get_descriptor(int fd)
{
if (fd <= 0 || fd >= PEACHOS_MAX_FILE_DESCRIPTORS)
{
return 0;
}
// Descriptors start at 1
int index = fd - 1;
return file_descriptors[index];
}
However, it should be
static struct file_descriptor* file_get_descriptor(int fd)
{
if (fd <= 0 || fd > PEACHOS_MAX_FILE_DESCRIPTORS)
{
return 0;
}
// Descriptors start at 1
int index = fd - 1;
return file_descriptors[index];
}
because PEACHOS_MAX_FILE_DESCRIPTORS is an allowable file descriptor because of adding 1 to all of them. You have, in essence, made it so that when you reach the maximum, you can allocate the last one, but not access it with this function.
In the Q&A you had asked me to check the final commit because you thought the bug had been fixed, but this issue is still in the current commit of the repo.
Metadata
Metadata
Assignees
Labels
No labels