mirror of
https://github.com/drasko/codezero.git
synced 2026-02-20 13:53:14 +01:00
Fixed the error that file length was referenced without checking that
the file pointer was valid.
This commit is contained in:
@@ -454,17 +454,22 @@ unsigned long find_unmapped_area(unsigned long npages, struct tcb *task)
|
|||||||
int do_mmap(struct vm_file *mapfile, unsigned long file_offset, struct tcb *task,
|
int do_mmap(struct vm_file *mapfile, unsigned long file_offset, struct tcb *task,
|
||||||
unsigned long map_address, unsigned int flags, unsigned int npages)
|
unsigned long map_address, unsigned int flags, unsigned int npages)
|
||||||
{
|
{
|
||||||
unsigned long file_npages = __pfn(page_align_up(mapfile->length));
|
unsigned long file_npages;
|
||||||
unsigned long map_pfn = __pfn(map_address);
|
unsigned long map_pfn = __pfn(map_address);
|
||||||
struct vm_area *new, *mapped;
|
struct vm_area *new, *mapped;
|
||||||
|
|
||||||
|
/* Set up devzero if none given */
|
||||||
if (!mapfile) {
|
if (!mapfile) {
|
||||||
if (flags & VMA_ANONYMOUS) {
|
if (flags & VMA_ANONYMOUS) {
|
||||||
mapfile = get_devzero();
|
mapfile = get_devzero();
|
||||||
file_offset = 0;
|
file_offset = 0;
|
||||||
} else
|
} else
|
||||||
BUG();
|
BUG();
|
||||||
} else if (npages > file_npages - file_offset) {
|
}
|
||||||
|
|
||||||
|
/* Get total file pages, check if mappin is within file size */
|
||||||
|
file_npages = __pfn(page_align_up(mapfile->length));
|
||||||
|
if (npages > file_npages - file_offset) {
|
||||||
printf("%s: Trying to map %d pages from page %d, "
|
printf("%s: Trying to map %d pages from page %d, "
|
||||||
"but file length is %d\n", __FUNCTION__,
|
"but file length is %d\n", __FUNCTION__,
|
||||||
npages, file_offset, file_npages);
|
npages, file_offset, file_npages);
|
||||||
|
|||||||
Reference in New Issue
Block a user