소스 검색

Add invalid cluster error checks

Bill Greiman 7 년 전
부모
커밋
ae1471ab39
3개의 변경된 파일10개의 추가작업 그리고 4개의 파일을 삭제
  1. 1 1
      library.properties
  2. 8 2
      src/FatLib/FatVolume.cpp
  3. 1 1
      src/SdFat.h

+ 1 - 1
library.properties

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

+ 8 - 2
src/FatLib/FatVolume.cpp

@@ -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);
@@ -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);

+ 1 - 1
src/SdFat.h

@@ -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