Skip to content

Commit

Permalink
Add invalid cluster error checks
Browse files Browse the repository at this point in the history
  • Loading branch information
greiman committed Dec 23, 2017
1 parent 18905d7 commit ae1471a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=SdFat
version=1.0.3
version=1.0.4
author=Bill Greiman <[email protected]>
maintainer=Bill Greiman <[email protected]>
sentence=FAT16/FAT32 file system for SD cards.
Expand Down
10 changes: 8 additions & 2 deletions src/FatLib/FatVolume.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,10 @@ int8_t FatVolume::fatGet(uint32_t cluster, uint32_t* value) {
cache_t* pc;

// 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) {
lba = m_fatStartBlock + (cluster >> 7);
Expand Down Expand Up @@ -266,7 +269,10 @@ bool FatVolume::fatPut(uint32_t cluster, uint32_t value) {
cache_t* pc;

// 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) {
lba = m_fatStartBlock + (cluster >> 7);
Expand Down
2 changes: 1 addition & 1 deletion src/SdFat.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
#include "SdCard/SdioCard.h"
//------------------------------------------------------------------------------
/** SdFat version */
#define SD_FAT_VERSION "1.0.3"
#define SD_FAT_VERSION "1.0.4"
//==============================================================================
/**
* \class SdBaseFile
Expand Down

0 comments on commit ae1471a

Please sign in to comment.