FreeCalypso > hg > freecalypso-sw
diff 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 |
line wrap: on
line diff
--- a/ffstools/tiffs-rd/inode.c Sun Jan 26 08:11:42 2014 +0000 +++ b/ffstools/tiffs-rd/inode.c Sun Jan 26 08:42:59 2014 +0000 @@ -4,6 +4,7 @@ #include <sys/types.h> #include <endian.h> +#include <ctype.h> #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -11,6 +12,7 @@ #include "types.h" #include "struct.h" #include "globals.h" +#include "pathname.h" u8 blank_flash_line[16] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}; @@ -159,3 +161,44 @@ fprintf(stderr, "error: no root inode found; try -r\n"); exit(1); } + +validate_obj_name(ino, root_special) +{ + struct inode_info *inf = inode_info[ino]; + u8 *p, *endp; + int c; + + if (!inf->len) + return(0); + p = inf->dataptr; + endp = p + inf->len; + for (; ; p++) { + if (p >= endp) + return(0); + c = *p; + if (!c) + break; + if (c < ' ' || c > '~') + return(0); + if (root_special || isalnum(c)) + continue; + switch (c) { + case '.': + case ',': + case '_': + case '-': + case '+': + case '%': + case '$': + case '#': + continue; + default: + return(0); + } + } + c = p - inf->dataptr; + if (c < 1 || c > MAX_FN_COMPONENT && !root_special) + return(0); + inf->byte_after_name = p + 1; + return(1); +}