Repository navigation
Commit f73fc08
authored
fix oob read in clangimport AST nodes with fewer than 2 ext tokens (#8939)
GotoStmt and NamespaceDecl in AstNode::createTokens, and
createTokensForCXXRecord, read mExtTokens[mExtTokens.size() - 2] without
checking the node carries two ext tokens. mExtTokens comes from
splitString() of a clang -ast-dump line (read via --clang) and can hold
one or zero entries for a crafted node, so size()-2 wraps around and the
access reads out of bounds. ASAN reports a heap-buffer-overflow at the
GotoStmt site for a dump whose GotoStmt line has a single token
(`\`-GotoStmt 0x3` inside a function body). The three size()-2 accesses
now check the token count first; valid dumps always carry the location
and name tokens so their output is unchanged. crash3 in
testclangimport.cpp covers all three node types.
Happy to add a `Fix #NNNN` reference once a trac ticket exists for this
(I don't have Trac access, so a maintainer would need to create it).1 parent e772b35 commit f73fc08
2 files changed
Lines changed: 27 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1139 | 1139 | | |
1140 | 1140 | | |
1141 | 1141 | | |
| 1142 | + | |
| 1143 | + | |
1142 | 1144 | | |
1143 | 1145 | | |
1144 | 1146 | | |
| |||
1228 | 1230 | | |
1229 | 1231 | | |
1230 | 1232 | | |
1231 | | - | |
1232 | | - | |
1233 | | - | |
| 1233 | + | |
| 1234 | + | |
| 1235 | + | |
| 1236 | + | |
| 1237 | + | |
| 1238 | + | |
1234 | 1239 | | |
1235 | 1240 | | |
1236 | 1241 | | |
| |||
1507 | 1512 | | |
1508 | 1513 | | |
1509 | 1514 | | |
1510 | | - | |
1511 | | - | |
1512 | | - | |
1513 | | - | |
| 1515 | + | |
| 1516 | + | |
| 1517 | + | |
| 1518 | + | |
| 1519 | + | |
| 1520 | + | |
1514 | 1521 | | |
1515 | 1522 | | |
1516 | 1523 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
142 | 142 | | |
143 | 143 | | |
144 | 144 | | |
| 145 | + | |
145 | 146 | | |
146 | 147 | | |
147 | 148 | | |
| |||
1429 | 1430 | | |
1430 | 1431 | | |
1431 | 1432 | | |
| 1433 | + | |
| 1434 | + | |
| 1435 | + | |
| 1436 | + | |
| 1437 | + | |
| 1438 | + | |
| 1439 | + | |
| 1440 | + | |
| 1441 | + | |
| 1442 | + | |
| 1443 | + | |
| 1444 | + | |
1432 | 1445 | | |
1433 | 1446 | | |
1434 | 1447 | | |
0 commit comments