FreeCalypso > hg > freecalypso-reveng
view pirollback/checknames.c @ 44:074237879eca
pirollback: name check implemented
author | Michael Spacefalcon <msokolov@ivan.Harhan.ORG> |
---|---|
date | Sat, 06 Jul 2013 21:31:55 +0000 |
parents | |
children | 78ac405716db |
line wrap: on
line source
#include <sys/types.h> #include <stdio.h> #include <stdlib.h> #include "types.h" #include "struct.h" #include "pathname.h" extern struct inode_info inode[]; extern int last_inode; static void check_inode(ino) { struct inode_info *in; u8 *cp; int cnt; in = inode + ino; switch (in->type) { case 0xE1: case 0xF1: case 0xF2: break; default: return; } for (cp = in->dataptr, cnt = 0; ; cp++, cnt++) { if (cnt >= in->len) { fprintf(stderr, "inode #%x: name expected at %x: length overrun\n", ino, in->offset); exit(1); } if (!*cp) break; if (cnt >= MAX_FN_COMPONENT) { fprintf(stderr, "inode #%x: name exceeds program limit of %d chars\n", ino, MAX_FN_COMPONENT); exit(1); } if (*cp < '!' || *cp > '~') { fprintf(stderr, "inode #%x: name expected at %x: bad character\n", ino, in->offset); exit(1); } } if (!cnt) { fprintf(stderr, "inode #%x: name expected at %x: null string\n", ino, in->offset); exit(1); } in->byte_after_name = cp + 1; } check_object_names() { int ino; for (ino = 1; ino <= last_inode; ino++) check_inode(ino); }