File tree Expand file tree Collapse file tree 2 files changed +17
-1
lines changed
cpp/ql/test/query-tests/Security/CWE/CWE-190/semmle Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -332,4 +332,13 @@ void ptr_diff_case() {
332
332
char * admin_begin_pos = strstr (user, " ADMIN" );
333
333
int offset = admin_begin_pos ? user - admin_begin_pos : 0 ;
334
334
malloc (offset); // GOOD
335
- }
335
+ }
336
+
337
+ void equality_barrier () {
338
+ int size1 = atoi (getenv (" USER" ));
339
+ int size2 = atoi (getenv (" USER" ));
340
+
341
+ if (size1 == size2) {
342
+ int * a = (int *)malloc (size1 * sizeof (int )); // GOOD
343
+ }
344
+ }
Original file line number Diff line number Diff line change @@ -95,5 +95,12 @@ int main(int argc, char** argv) {
95
95
}
96
96
}
97
97
98
+ // GOOD: check the user input first
99
+ int maxConnections3 = atoi (argv [1 ]);
100
+ int maxConnections4 = atoi (argv [1 ]);
101
+ if (maxConnections3 == maxConnections4 ) {
102
+ startServer (maxConnections3 * 1000 );
103
+ }
104
+
98
105
return 0 ;
99
106
}
You can’t perform that action at this time.
0 commit comments