FAT: get_fatent: Fix FAT boundary check
PATCH 1/7 FAT: get_fatent: Fix FAT boundary check
startblock must be taken into account in order not to read past the end of the FAT.
Signed-off-by Beno?t Th?baudeau <[email protected]>
Cc Wolfgang Denk <[email protected]>
--- .../fs/fat/fat.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
fs/fat/fat.c +2 -2
@@ -207,8 +207,8 @@ static __u32 get_fatent (fsdata *mydata, __u32 entry)__u32 fatlength = mydata->fatlength;__u32 startblock = bufnum *FATBUFBLOCKS ; -if (getsize > fatlength) - getsize = fatlength; +if (startblock + getsize > fatlength) + getsize = fatlength - startblock; fatlength *= mydata->sect_size;/* We want it in bytes now */ startblock += mydata->fat_sect;/* Offset from start of disk */
PATCH v2 2/8 FAT: get_fatent: Fix FAT boundary check
startblock must be taken into account in order not to read past the end of the FAT.
Signed-off-by Beno?t Th?baudeau <[email protected]>
Cc Wolfgang Denk <[email protected]>
---
Changes for v2:
- Patch renumbering because of the new v2 1/8.
- Possible code style changes due to the new v2 1/8.
.../fs/fat/fat.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
fs/fat/fat.c +2 -2
@@ -207,8 +207,8 @@ static __u32 get_fatent(fsdata *mydata, __u32 entry)__u32 fatlength = mydata->fatlength;__u32 startblock = bufnum *FATBUFBLOCKS ; -if (getsize > fatlength) - getsize = fatlength; +if (startblock + getsize > fatlength) + getsize = fatlength - startblock; fatlength *= mydata->sect_size;/* We want it in bytes now */ startblock += mydata->fat_sect;/* Offset from start of disk */
Wolfgang Denk
AppliedPATCH v2 2/8 FAT: get_fatent: Fix FAT boundary check
Dear Beno?t Th?baudeau,
Quoted 6 lines · In message <[email protected]> you…
startblock must be taken into account in order not to read past the end of = the
FAT.Signed-off-by Beno?t Th?baudeau <[email protected]>Cc Wolfgang Denk <[email protected]>
Quoted 7 lines
---
Changes for v2:
- Patch renumbering because of the new v2 1/8.
- Possible code style changes due to the new v2 1/8..../fs/fat/fat.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
Applied, thanks.
Best regards,
Wolfgang Denk
Signature · 6 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Any sufficiently advanced technology is indistinguishable from magic.
Clarke's Third Law - _Profiles of the Future_ (1962; rev. 1973)
``Hazards of Prophecy: The Failure of Imagination''