From 6c1a808052ba6a875df7aa450b6df4b199f3a281 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Br=C3=BCns?= Date: Sat, 17 Dec 2016 00:27:50 +0100 Subject: fs/fat: Avoid corruption of sectors following the FAT MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The FAT is read/flushed in segments of 6 (FATBUFBLOCKS) disk sectors. The last segment may be less than 6 sectors, cap the length. Signed-off-by: Stefan Brüns Reviewed-by: Benoît Thébaudeau --- fs/fat/fat.c | 1 + 1 file changed, 1 insertion(+) (limited to 'fs/fat/fat.c') diff --git a/fs/fat/fat.c b/fs/fat/fat.c index df9f2b5656..6319581406 100644 --- a/fs/fat/fat.c +++ b/fs/fat/fat.c @@ -202,6 +202,7 @@ static __u32 get_fatent(fsdata *mydata, __u32 entry) __u32 fatlength = mydata->fatlength; __u32 startblock = bufnum * FATBUFBLOCKS; + /* Cap length if fatlength is not a multiple of FATBUFBLOCKS */ if (startblock + getsize > fatlength) getsize = fatlength - startblock; -- cgit v1.2.1