MCPcopy Create free account
hub / github.com/cgsecurity/testdisk / check_FAT_dir_entry

Function check_FAT_dir_entry

src/fat_adv.c:100–150  ·  view source on GitHub ↗

* 0 entry is free * 1 entry is used * 2 not an entry * */

Source from the content-addressed store, hash-verified

98 * 2 not an entry
99 * */
100static int check_FAT_dir_entry(const unsigned char *entry, const unsigned int entry_nr)
101{
102 int i;
103 if((entry[0xB]&ATTR_EXT_MASK)==ATTR_EXT)
104 return 1;
105/* log_trace("check_FAT_dir_entry %02x\n",*(entry+0)); */
106 if(entry[0]==0)
107 {
108 for(i=0;i<0x20;i++)
109 if(entry[i]!='\0')
110 return 2;
111 return 0;
112 }
113 if(entry[0]==0x20)
114 return 2;
115 if(entry[0]==0xE5)
116 return 1;
117 if(entry_nr<10 && (entry[0xB]&ATTR_VOLUME)==ATTR_VOLUME)
118 return 1;
119 for(i=0;i<8+3;i++)
120 {
121 const unsigned char car=entry[i];
122 if((car>=0x06 && car<=0x1f)||
123 (car>=0x3a && car<=0x3f)||
124 (car>='a' && car<='z'))
125 return 2;
126 switch(car)
127 {
128 case 0x1:
129 case 0x2:
130 case 0x3:
131 case 0x4:
132 case '"':
133 case '*':
134 case '+':
135 case ',':
136 case '.':
137 case '/':
138 case '[':
139 case '\\':
140 case ']':
141 case '|':
142/*log_trace("check_FAT_dir_entry bad %c (%02x)\n",car,car); */
143 return 2;
144 default:
145/*log_trace("check_FAT_dir_entry good %c (%02x)\n",car,car); */
146 break;
147 }
148 }
149 return 1;
150}
151
152/* */
153

Callers 4

fat32_find_root_clusterFunction · 0.85
find_dir_entriesFunction · 0.85
analyse_dir_entriesFunction · 0.85
FAT_init_rootdirFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected