Skip to content

Commit ae1471a

Browse files
committed
Add invalid cluster error checks
1 parent 18905d7 commit ae1471a

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=SdFat
2-
version=1.0.3
2+
version=1.0.4
33
author=Bill Greiman <[email protected]>
44
maintainer=Bill Greiman <[email protected]>
55
sentence=FAT16/FAT32 file system for SD cards.

src/FatLib/FatVolume.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,10 @@ int8_t FatVolume::fatGet(uint32_t cluster, uint32_t* value) {
200200
cache_t* pc;
201201

202202
// error if reserved cluster of beyond FAT
203-
DBG_HALT_IF(cluster < 2 || cluster > m_lastCluster);
203+
if (cluster < 2 || cluster > m_lastCluster) {
204+
DBG_FAIL_MACRO;
205+
goto fail;
206+
}
204207

205208
if (fatType() == 32) {
206209
lba = m_fatStartBlock + (cluster >> 7);
@@ -266,7 +269,10 @@ bool FatVolume::fatPut(uint32_t cluster, uint32_t value) {
266269
cache_t* pc;
267270

268271
// error if reserved cluster of beyond FAT
269-
DBG_HALT_IF(cluster < 2 || cluster > m_lastCluster);
272+
if (cluster < 2 || cluster > m_lastCluster) {
273+
DBG_FAIL_MACRO;
274+
goto fail;
275+
}
270276

271277
if (fatType() == 32) {
272278
lba = m_fatStartBlock + (cluster >> 7);

src/SdFat.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
#include "SdCard/SdioCard.h"
3535
//------------------------------------------------------------------------------
3636
/** SdFat version */
37-
#define SD_FAT_VERSION "1.0.3"
37+
#define SD_FAT_VERSION "1.0.4"
3838
//==============================================================================
3939
/**
4040
* \class SdBaseFile

0 commit comments

Comments
 (0)