FreeCalypso > hg > freecalypso-sw
comparison ffstools/tiffs-rd/inode.c @ 232:73372cfdaf7f
tiffs IVA: object name validation implemented
author | Michael Spacefalcon <msokolov@ivan.Harhan.ORG> |
---|---|
date | Sun, 26 Jan 2014 08:42:59 +0000 |
parents | 5ceacdbd4490 |
children | ae9ff2d1e3da |
comparison
equal
deleted
inserted
replaced
231:5ceacdbd4490 | 232:73372cfdaf7f |
---|---|
2 * This C module implements the reading and decoding of inode information. | 2 * This C module implements the reading and decoding of inode information. |
3 */ | 3 */ |
4 | 4 |
5 #include <sys/types.h> | 5 #include <sys/types.h> |
6 #include <endian.h> | 6 #include <endian.h> |
7 #include <ctype.h> | |
7 #include <stdio.h> | 8 #include <stdio.h> |
8 #include <stdlib.h> | 9 #include <stdlib.h> |
9 #include <string.h> | 10 #include <string.h> |
10 #include <strings.h> | 11 #include <strings.h> |
11 #include "types.h" | 12 #include "types.h" |
12 #include "struct.h" | 13 #include "struct.h" |
13 #include "globals.h" | 14 #include "globals.h" |
15 #include "pathname.h" | |
14 | 16 |
15 u8 blank_flash_line[16] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, | 17 u8 blank_flash_line[16] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, |
16 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}; | 18 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}; |
17 | 19 |
18 alloc_inode_table() | 20 alloc_inode_table() |
157 return(0); | 159 return(0); |
158 } | 160 } |
159 fprintf(stderr, "error: no root inode found; try -r\n"); | 161 fprintf(stderr, "error: no root inode found; try -r\n"); |
160 exit(1); | 162 exit(1); |
161 } | 163 } |
164 | |
165 validate_obj_name(ino, root_special) | |
166 { | |
167 struct inode_info *inf = inode_info[ino]; | |
168 u8 *p, *endp; | |
169 int c; | |
170 | |
171 if (!inf->len) | |
172 return(0); | |
173 p = inf->dataptr; | |
174 endp = p + inf->len; | |
175 for (; ; p++) { | |
176 if (p >= endp) | |
177 return(0); | |
178 c = *p; | |
179 if (!c) | |
180 break; | |
181 if (c < ' ' || c > '~') | |
182 return(0); | |
183 if (root_special || isalnum(c)) | |
184 continue; | |
185 switch (c) { | |
186 case '.': | |
187 case ',': | |
188 case '_': | |
189 case '-': | |
190 case '+': | |
191 case '%': | |
192 case '$': | |
193 case '#': | |
194 continue; | |
195 default: | |
196 return(0); | |
197 } | |
198 } | |
199 c = p - inf->dataptr; | |
200 if (c < 1 || c > MAX_FN_COMPONENT && !root_special) | |
201 return(0); | |
202 inf->byte_after_name = p + 1; | |
203 return(1); | |
204 } |