Skip to content

Commit 333e607

Browse files
authored
Merge pull request github#14376 from MathiasVP/unique-in-hasIRRepresentationOfIndirectInstruction
2 parents 399fab0 + e38f659 commit 333e607

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal/SsaInternalsCommon.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -815,7 +815,7 @@ private module Cached {
815815
) {
816816
indirectionIndex = [1 .. countIndirectionsForCppType(getResultLanguageType(instr))] and
817817
exists(Instruction load, Operand address |
818-
address.getDef() = instr and
818+
address = unique( | | getAUse(instr)) and
819819
isDereference(load, address, false) and
820820
instrRepr = load and
821821
indirectionIndexRepr = indirectionIndex - 1

cpp/ql/test/experimental/query-tests/Security/CWE/CWE-193/constant-size/ConstantSizeArrayOffByOne.expected

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ edges
3636
| test.cpp:143:18:143:21 | asdf | test.cpp:134:25:134:27 | arr |
3737
| test.cpp:143:18:143:21 | asdf | test.cpp:143:18:143:21 | asdf |
3838
| test.cpp:146:26:146:26 | p indirection | test.cpp:148:6:148:9 | * ... |
39+
| test.cpp:146:26:146:26 | p indirection | test.cpp:149:6:149:9 | * ... |
40+
| test.cpp:146:26:146:26 | p indirection | test.cpp:150:6:150:9 | * ... |
3941
| test.cpp:156:12:156:14 | buf | test.cpp:156:12:156:18 | ... + ... |
4042
| test.cpp:156:12:156:18 | ... + ... | test.cpp:158:17:158:18 | & ... indirection |
4143
| test.cpp:158:17:158:18 | & ... indirection | test.cpp:146:26:146:26 | p indirection |
@@ -123,6 +125,8 @@ nodes
123125
| test.cpp:143:18:143:21 | asdf | semmle.label | asdf |
124126
| test.cpp:146:26:146:26 | p indirection | semmle.label | p indirection |
125127
| test.cpp:148:6:148:9 | * ... | semmle.label | * ... |
128+
| test.cpp:149:6:149:9 | * ... | semmle.label | * ... |
129+
| test.cpp:150:6:150:9 | * ... | semmle.label | * ... |
126130
| test.cpp:156:12:156:14 | buf | semmle.label | buf |
127131
| test.cpp:156:12:156:18 | ... + ... | semmle.label | ... + ... |
128132
| test.cpp:158:17:158:18 | & ... indirection | semmle.label | & ... indirection |
@@ -176,6 +180,8 @@ subpaths
176180
| test.cpp:128:9:128:14 | PointerAdd: access to array | test.cpp:128:9:128:11 | arr | test.cpp:128:9:128:14 | access to array | This pointer arithmetic may have an off-by-1 error allowing it to overrun $@ at this $@. | test.cpp:125:11:125:13 | arr | arr | test.cpp:128:9:128:18 | Store: ... = ... | write |
177181
| test.cpp:136:9:136:16 | PointerAdd: ... += ... | test.cpp:143:18:143:21 | asdf | test.cpp:138:13:138:15 | arr | This pointer arithmetic may have an off-by-2 error allowing it to overrun $@ at this $@. | test.cpp:142:10:142:13 | asdf | asdf | test.cpp:138:12:138:15 | Load: * ... | read |
178182
| test.cpp:156:12:156:18 | PointerAdd: ... + ... | test.cpp:156:12:156:14 | buf | test.cpp:148:6:148:9 | * ... | This pointer arithmetic may have an off-by-1 error allowing it to overrun $@ at this $@. | test.cpp:154:7:154:9 | buf | buf | test.cpp:147:3:147:13 | Store: ... = ... | write |
183+
| test.cpp:156:12:156:18 | PointerAdd: ... + ... | test.cpp:156:12:156:14 | buf | test.cpp:149:6:149:9 | * ... | This pointer arithmetic may have an off-by-1 error allowing it to overrun $@ at this $@. | test.cpp:154:7:154:9 | buf | buf | test.cpp:148:3:148:13 | Store: ... = ... | write |
184+
| test.cpp:156:12:156:18 | PointerAdd: ... + ... | test.cpp:156:12:156:14 | buf | test.cpp:150:6:150:9 | * ... | This pointer arithmetic may have an off-by-1 error allowing it to overrun $@ at this $@. | test.cpp:154:7:154:9 | buf | buf | test.cpp:149:3:149:13 | Store: ... = ... | write |
179185
| test.cpp:221:5:221:11 | PointerAdd: access to array | test.cpp:218:23:218:28 | buffer | test.cpp:221:5:221:11 | access to array | This pointer arithmetic may have an off-by-1 error allowing it to overrun $@ at this $@. | test.cpp:217:19:217:24 | buffer | buffer | test.cpp:221:5:221:15 | Store: ... = ... | write |
180186
| test.cpp:232:5:232:10 | PointerAdd: access to array | test.cpp:229:25:229:29 | array | test.cpp:232:5:232:10 | access to array | This pointer arithmetic may have an off-by-1 error allowing it to overrun $@ at this $@. | test.cpp:228:10:228:14 | array | array | test.cpp:232:5:232:19 | Store: ... = ... | write |
181187
| test.cpp:261:27:261:30 | PointerAdd: access to array | test.cpp:286:19:286:25 | buffer2 | test.cpp:261:27:261:30 | access to array | This pointer arithmetic may have an off-by-1 error allowing it to overrun $@ at this $@. | test.cpp:285:19:285:25 | buffer2 | buffer2 | test.cpp:261:27:261:30 | Load: access to array | read |

0 commit comments

Comments
 (0)