FreeCalypso > hg > freecalypso-reveng
annotate 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 |
rev | line source |
---|---|
44
074237879eca
pirollback: name check implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1 #include <sys/types.h> |
074237879eca
pirollback: name check implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2 #include <stdio.h> |
074237879eca
pirollback: name check implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3 #include <stdlib.h> |
074237879eca
pirollback: name check implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
4 #include "types.h" |
074237879eca
pirollback: name check implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
5 #include "struct.h" |
074237879eca
pirollback: name check implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
6 #include "pathname.h" |
074237879eca
pirollback: name check implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
7 |
074237879eca
pirollback: name check implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
8 extern struct inode_info inode[]; |
074237879eca
pirollback: name check implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
9 extern int last_inode; |
074237879eca
pirollback: name check implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
10 |
074237879eca
pirollback: name check implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
11 static void |
074237879eca
pirollback: name check implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
12 check_inode(ino) |
074237879eca
pirollback: name check implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
13 { |
074237879eca
pirollback: name check implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
14 struct inode_info *in; |
074237879eca
pirollback: name check implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
15 u8 *cp; |
074237879eca
pirollback: name check implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
16 int cnt; |
074237879eca
pirollback: name check implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
17 |
074237879eca
pirollback: name check implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
18 in = inode + ino; |
074237879eca
pirollback: name check implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
19 switch (in->type) { |
074237879eca
pirollback: name check implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
20 case 0xE1: |
074237879eca
pirollback: name check implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
21 case 0xF1: |
074237879eca
pirollback: name check implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
22 case 0xF2: |
074237879eca
pirollback: name check implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
23 break; |
074237879eca
pirollback: name check implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
24 default: |
074237879eca
pirollback: name check implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
25 return; |
074237879eca
pirollback: name check implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
26 } |
074237879eca
pirollback: name check implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
27 for (cp = in->dataptr, cnt = 0; ; cp++, cnt++) { |
074237879eca
pirollback: name check implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
28 if (cnt >= in->len) { |
074237879eca
pirollback: name check implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
29 fprintf(stderr, |
074237879eca
pirollback: name check implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
30 "inode #%x: name expected at %x: length overrun\n", |
074237879eca
pirollback: name check implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
31 ino, in->offset); |
074237879eca
pirollback: name check implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
32 exit(1); |
074237879eca
pirollback: name check implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
33 } |
074237879eca
pirollback: name check implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
34 if (!*cp) |
074237879eca
pirollback: name check implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
35 break; |
074237879eca
pirollback: name check implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
36 if (cnt >= MAX_FN_COMPONENT) { |
074237879eca
pirollback: name check implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
37 fprintf(stderr, |
074237879eca
pirollback: name check implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
38 "inode #%x: name exceeds program limit of %d chars\n", |
074237879eca
pirollback: name check implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
39 ino, MAX_FN_COMPONENT); |
074237879eca
pirollback: name check implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
40 exit(1); |
074237879eca
pirollback: name check implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
41 } |
074237879eca
pirollback: name check implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
42 if (*cp < '!' || *cp > '~') { |
074237879eca
pirollback: name check implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
43 fprintf(stderr, |
074237879eca
pirollback: name check implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
44 "inode #%x: name expected at %x: bad character\n", |
074237879eca
pirollback: name check implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
45 ino, in->offset); |
074237879eca
pirollback: name check implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
46 exit(1); |
074237879eca
pirollback: name check implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
47 } |
074237879eca
pirollback: name check implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
48 } |
074237879eca
pirollback: name check implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
49 if (!cnt) { |
074237879eca
pirollback: name check implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
50 fprintf(stderr, "inode #%x: name expected at %x: null string\n", |
074237879eca
pirollback: name check implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
51 ino, in->offset); |
074237879eca
pirollback: name check implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
52 exit(1); |
074237879eca
pirollback: name check implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
53 } |
074237879eca
pirollback: name check implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
54 in->byte_after_name = cp + 1; |
074237879eca
pirollback: name check implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
55 } |
074237879eca
pirollback: name check implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
56 |
074237879eca
pirollback: name check implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
57 check_object_names() |
074237879eca
pirollback: name check implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
58 { |
074237879eca
pirollback: name check implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
59 int ino; |
074237879eca
pirollback: name check implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
60 |
074237879eca
pirollback: name check implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
61 for (ino = 1; ino <= last_inode; ino++) |
074237879eca
pirollback: name check implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
62 check_inode(ino); |
074237879eca
pirollback: name check implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
63 } |