Add invalid cluster error checks

This commit is contained in:
Bill Greiman 2017-12-23 05:44:26 -08:00
parent 18905d728f
commit ae1471ab39
3 changed files with 10 additions and 4 deletions

View file

@ -1,5 +1,5 @@
name=SdFat name=SdFat
version=1.0.3 version=1.0.4
author=Bill Greiman <fat16lib@sbcglobal.net> author=Bill Greiman <fat16lib@sbcglobal.net>
maintainer=Bill Greiman <fat16lib@sbcglobal.net> maintainer=Bill Greiman <fat16lib@sbcglobal.net>
sentence=FAT16/FAT32 file system for SD cards. sentence=FAT16/FAT32 file system for SD cards.

View file

@ -200,7 +200,10 @@ int8_t FatVolume::fatGet(uint32_t cluster, uint32_t* value) {
cache_t* pc; cache_t* pc;
// error if reserved cluster of beyond FAT // error if reserved cluster of beyond FAT
DBG_HALT_IF(cluster < 2 || cluster > m_lastCluster); if (cluster < 2 || cluster > m_lastCluster) {
DBG_FAIL_MACRO;
goto fail;
}
if (fatType() == 32) { if (fatType() == 32) {
lba = m_fatStartBlock + (cluster >> 7); lba = m_fatStartBlock + (cluster >> 7);
@ -266,7 +269,10 @@ bool FatVolume::fatPut(uint32_t cluster, uint32_t value) {
cache_t* pc; cache_t* pc;
// error if reserved cluster of beyond FAT // error if reserved cluster of beyond FAT
DBG_HALT_IF(cluster < 2 || cluster > m_lastCluster); if (cluster < 2 || cluster > m_lastCluster) {
DBG_FAIL_MACRO;
goto fail;
}
if (fatType() == 32) { if (fatType() == 32) {
lba = m_fatStartBlock + (cluster >> 7); lba = m_fatStartBlock + (cluster >> 7);

View file

@ -34,7 +34,7 @@
#include "SdCard/SdioCard.h" #include "SdCard/SdioCard.h"
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
/** SdFat version */ /** SdFat version */
#define SD_FAT_VERSION "1.0.3" #define SD_FAT_VERSION "1.0.4"
//============================================================================== //==============================================================================
/** /**
* \class SdBaseFile * \class SdBaseFile