From 4bdc29d70b04827f0e9d18220f129e601ac70ab0 Mon Sep 17 00:00:00 2001 From: neil Date: Sun, 7 Jun 2015 07:05:46 +0000 Subject: [PATCH] Prevent access beyond end of root directory (FAT12/FAT16). git-svn-id: https://svn.aros.org/svn/aros/trunk/AROS@50782 fb15a70f-31f2-0310-bbcc-cdcc74a49acc --- rom/filesys/fat/file.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/rom/filesys/fat/file.c b/rom/filesys/fat/file.c index 4f3df73ff6..2173b730ee 100644 --- a/rom/filesys/fat/file.c +++ b/rom/filesys/fat/file.c @@ -2,7 +2,7 @@ * fat-handler - FAT12/16/32 filesystem handler * * Copyright © 2006 Marek Szyprowski - * Copyright © 2007-2011 The AROS Development Team + * Copyright © 2007-2015 The AROS Development Team * * This program is free software; you can redistribute it and/or modify it * under the same terms as AROS itself. @@ -148,6 +148,13 @@ LONG ReadFileChunk(struct IOHandle *ioh, ULONG file_pos, ULONG nwant, ioh->sector_offset = sector_offset - ioh->first_sector; ioh->cur_sector = ioh->first_sector + sector_offset; + /* Stop if we've reached the end of the root dir */ + if (ioh->cur_sector >= ioh->sb->first_rootdir_sector + + ioh->sb->rootdir_sectors) { + RESET_HANDLE(ioh); + return ERROR_OBJECT_NOT_FOUND; + } + D(bug("[fat] adjusted for cluster 0, chunk starts in sector %ld\n", ioh->cur_sector)); } else -- 2.11.4.GIT