This repository was archived by the owner on Jun 16, 2025. It is now read-only.
Commit a701332
committed
Various macros assume the argument is not negative
This cuts the ASAN failures in half. From 42 to 20 on my macOS server.
Macros like `isaletter()` assume the argument is not negative. But
there is at least one place where it is called with a value of -1 from
fcget(). Specifically, in `sh_lex()`:
case S_DOT: {
// Make sure next character is alpha.
n = fcgetc();
if (n > 0) {
if (n == '.') n = fcgetc();
if (n > 0) fcseek(-LEN);
}
if (isaletter(n) || n == LBRACT) continue;
In the rksh.sh unit test `n` is -1 thus causing a reference to the element
before one of the lexer state tables.
Harden those macros against that possibility so they don't use some
random data.
Related #9711 parent 788759f commit a701332
1 file changed
Lines changed: 5 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
91 | 91 | | |
92 | 92 | | |
93 | 93 | | |
94 | | - | |
95 | | - | |
96 | 94 | | |
97 | | - | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
98 | 98 | | |
99 | | - | |
100 | | - | |
| 99 | + | |
| 100 | + | |
101 | 101 | | |
102 | 102 | | |
103 | 103 | | |
| |||
0 commit comments