11
11
result = len; \
12
12
}
13
13
char tempbuf[16 ];
14
+ int tempnum;
14
15
void get_lexdata (char buf1[],char buf2[]);
15
16
%}
16
17
@@ -55,8 +56,30 @@ IP { yylval.flag=IP; yylval.flag2=0; return(0); }
55
56
PTBR { yylval.flag =PTBR; yylval.flag2 =0 ; return (0 ); }
56
57
PTLR { yylval.flag =PTLR; yylval.flag2 =0 ; return (0 ); }
57
58
EFR { yylval.flag =EFR; yylval.flag2 =0 ; return (0 ); }
58
- R[0 -9 ]+ { yylval.flag =REG; yylval.flag2 =0 ; yytext++; return (atoi (yytext)); }
59
- T[0 -9 ]+ { yylval.flag =REG; yylval.flag2 =0 ; yytext++; return (atoi (yytext) + T0); }
59
+ R[0 -9 ]+ {
60
+ yylval.flag =REG; yylval.flag2 =0 ;
61
+ yytext++;
62
+ tempnum = atoi (yytext);
63
+ if (tempnum > 7 )
64
+ return ILLREG;
65
+ return (tempnum + R0);
66
+ }
67
+ S[0 -9 ]+ {
68
+ yylval.flag =REG; yylval.flag2 =0 ;
69
+ yytext++;
70
+ tempnum = atoi (yytext);
71
+ if (tempnum > 15 )
72
+ return ILLREG;
73
+ return (tempnum + S0);
74
+ }
75
+ T[0 -9 ]+ {
76
+ yylval.flag =REG; yylval.flag2 =0 ;
77
+ yytext++;
78
+ tempnum = atoi (yytext);
79
+ if (tempnum > 3 )
80
+ return ILLREG;
81
+ return (tempnum + T0);
82
+ }
60
83
\[ SP\] { yylval.flag =MEM_SP; yylval.flag2 =0 ; return (0 ); }
61
84
\[ BP\] { yylval.flag =MEM_BP; yylval.flag2 =0 ; return (0 ); }
62
85
\[ IP\] { yylval.flag =MEM_IP; yylval.flag2 =0 ; return (0 ); } // error: Is this needed.
@@ -67,13 +90,28 @@ T[0-9]+ { yylval.flag=REG; yylval.flag2=0; yytext++; return(atoi(yytext) + T0);
67
90
yylval.flag =MEM_REG; yylval.flag2 =0 ;
68
91
yytext[yyleng-1 ]=' \0 ' ;
69
92
yytext=yytext+2 ;
70
- return (atoi (yytext));
71
- }
93
+ tempnum = atoi (yytext);
94
+ if (tempnum > 7 )
95
+ return ILLREG;
96
+ return (tempnum + R0);
97
+ }
98
+ \[ S[0 -9 ]+ \] {
99
+ yylval.flag =MEM_REG; yylval.flag2 =0 ;
100
+ yytext[yyleng-1 ]=' \0 ' ;
101
+ yytext=yytext+2 ;
102
+ tempnum = atoi (yytext);
103
+ if (tempnum > 15 )
104
+ return ILLREG;
105
+ return (tempnum + S0);
106
+ }
72
107
\[ T[0 -9 ]+ \] {
73
108
yylval.flag =MEM_REG; yylval.flag2 =0 ;
74
109
yytext[yyleng-1 ]=' \0 ' ;
75
110
yytext=yytext+2 ;
76
- return (atoi (yytext) + T0);
111
+ tempnum = atoi (yytext);
112
+ if (tempnum > 3 )
113
+ return ILLREG;
114
+ return (tempnum + T0);
77
115
}
78
116
-? [0 -9 ]+ { yylval.flag =NUM; yylval.flag2 =0 ; return (atoi (yytext)); }
79
117
\[ [0 -9 ]+ \] {
@@ -86,14 +124,33 @@ T[0-9]+ { yylval.flag=REG; yylval.flag2=0; yytext++; return(atoi(yytext) + T0);
86
124
yylval.flag =MEM_DIR_REG;
87
125
yytext++;
88
126
get_lexdata (yytext,tempbuf); // Not at all tested. Vulnerable ***
89
- yylval.flag2 =atoi (tempbuf);
127
+ tempnum = atoi (tempbuf);
128
+ if (tempnum > 7 )
129
+ yylval.flag2 = ILLREG;
130
+ else
131
+ yylval.flag2 = tempnum + R0;
132
+ return (atoi (yytext));
133
+ }
134
+ \[ -? [0 -9 ]+ \] S[0 -9 ]+ {
135
+ yylval.flag =MEM_DIR_REG;
136
+ yytext++;
137
+ get_lexdata (yytext,tempbuf); // Not at all tested. Vulnerable ***
138
+ tempnum = atoi (tempbuf);
139
+ if (tempnum > 15 )
140
+ yylval.flag2 = ILLREG;
141
+ else
142
+ yylval.flag2 = tempnum + S0;
90
143
return (atoi (yytext));
91
144
}
92
145
\[ -? [0 -9 ]+ \] T[0 -9 ]+ {
93
146
yylval.flag =MEM_DIR_REG;
94
147
yytext++;
95
148
get_lexdata (yytext,tempbuf); // Not at all tested. Vulnerable ***
96
- yylval.flag2 =atoi (tempbuf) + T0;
149
+ tempnum = atoi (tempbuf);
150
+ if (tempnum > 3 )
151
+ yylval.flag2 = ILLREG;
152
+ else
153
+ yylval.flag2 = tempnum + T0;
97
154
return (atoi (yytext));
98
155
}
99
156
\[ -? [0 -9 ]+ \] SP {
@@ -175,7 +232,7 @@ void get_lexdata(char buf1[],char buf2[]) //Not at all tested. Vulnerable ***
175
232
flag = 1 ;
176
233
j=0 ;
177
234
buf1[i]=' \0 ' ;
178
- if (buf1[i+1 ] == ' R' || buf1[i+1 ] == ' T' )
235
+ if (buf1[i+1 ] == ' R' || buf1[i+1 ] == ' S ' || buf1[i+ 1 ] == ' T' )
179
236
{
180
237
i++;
181
238
buf1[i]=' \0 ' ;
0 commit comments