Commit 8d57369
committed
Fix buffer overflow in sh_lex()
This macro expansion in lex.c may assign -1 to n if EOF is reached:
1178: fcgetc(n);
As a result, n may be -1 when this code is reached:
1190: if(sh_isoption(SH_BRACEEXPAND) && c==LBRACE && !assignment
&& state[n]!=S_BREAK
'state[n]' is a buffer overflow if n==-1.
src/cmd/ksh93/sh/lex.c: sh_lex(): case S_BRACE:
- Apart from the buffer overflow, if n<=0, none of the code
following fcget(n) does anything until 'break' on line 1199 is
reached. So, if fcget(n) yields <=0, just break. This allows some
code simplification.
Progresses: ksh93/ksh#5181 parent 59a5672 commit 8d57369
1 file changed
+3
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1175 | 1175 | | |
1176 | 1176 | | |
1177 | 1177 | | |
1178 | | - | |
| 1178 | + | |
| 1179 | + | |
1179 | 1180 | | |
1180 | 1181 | | |
1181 | 1182 | | |
1182 | | - | |
1183 | | - | |
1184 | | - | |
1185 | | - | |
| 1183 | + | |
1186 | 1184 | | |
1187 | 1185 | | |
1188 | 1186 | | |
| |||
0 commit comments