From 85e7e13bb05ff1fa19f9c1da4531df3c1a662610 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Tue, 14 Jan 2014 13:45:26 -0600 Subject: [PATCH] Fix a FAT cluster allocation bug. From Tridge --- ChangeLog | 5 ++++- fs/fat/fs_fat32.c | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index b7039d0703..9c08ef7c7d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -6433,4 +6433,7 @@ * configs/px4fmu-v2_upstream: Configuration for testing simple configurations on the the PX4FMU v2. This version is incomplete for the PX4 appliation and is not a replacement for the version - in the PX4 GIT repository. \ No newline at end of file + in the PX4 GIT repository. + * fs/fat/fs_fat32.c: A correction to FAT cluster allocation from + Tridge via Lorenz Meier (2014-1-14). + diff --git a/fs/fat/fs_fat32.c b/fs/fat/fs_fat32.c index 29d5b450ff..cbbc3cd894 100644 --- a/fs/fat/fs_fat32.c +++ b/fs/fat/fs_fat32.c @@ -623,7 +623,7 @@ fat_read_restart: * cluster boundary */ - if (ff->ff_sectorsincluster < 1) + if (buflen > 0 && ff->ff_sectorsincluster < 1) { /* Find the next cluster in the FAT. */ @@ -899,7 +899,7 @@ fat_write_restart: * cluster boundary */ - if (ff->ff_sectorsincluster < 1) + if (buflen > 0 && ff->ff_sectorsincluster < 1) { /* Extend the current cluster by one (unless lseek was used to * move the file position back from the end of the file)