Skip to content

Commit 93286aa

Browse files
committed
C++: Test for FP introduced by relOp changes
1 parent 2140995 commit 93286aa

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

cpp/ql/test/query-tests/Likely Bugs/Format/SnprintfOverflow/SnprintfOverflow.expected

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
| test.cpp:62:12:62:19 | call to snprintf | The $@ of this snprintf call is derived from its return value, which may exceed the size of the buffer and overflow. | test.cpp:62:26:62:34 | remaining | size argument |
33
| test.cpp:76:10:76:17 | call to snprintf | The $@ of this snprintf call is derived from its return value, which may exceed the size of the buffer and overflow. | test.cpp:76:24:76:32 | ... - ... | size argument |
44
| test.cpp:100:10:100:19 | call to snprintf_s | The $@ of this snprintf call is derived from its return value, which may exceed the size of the buffer and overflow. | test.cpp:100:35:100:54 | ... - ... | size argument |
5+
| test.cpp:109:15:109:22 | call to snprintf | The $@ of this snprintf call is derived from its return value, which may exceed the size of the buffer and overflow. | test.cpp:109:29:109:35 | buf_len | size argument |

cpp/ql/test/query-tests/Likely Bugs/Format/SnprintfOverflow/test.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,3 +103,15 @@ void test7(const char *strings) // separated by \0, terminated by \0\0
103103
strings += strlen(strings) + 1;
104104
}
105105
}
106+
107+
void concat_strings(char *buf, size_t buf_len, const char **strings, size_t n_strings) {
108+
while (n_strings > 0) {
109+
int ret = snprintf(buf, buf_len, "%s", *strings); // GOOD [FALSE POSITIVE]
110+
if (ret > buf_len)
111+
return;
112+
buf_len -= ret;
113+
buf += ret;
114+
n_strings--;
115+
strings++;
116+
}
117+
}

0 commit comments

Comments
 (0)