mirror of
https://github.com/github/codeql.git
synced 2026-05-05 21:55:19 +02:00
Merge branch 'main' into unsigneddiff2
This commit is contained in:
@@ -3,6 +3,4 @@
|
||||
| test.c:50:3:50:5 | sc3 | $@ flows to here and is used in arithmetic, potentially causing an overflow. | test.c:49:9:49:16 | 127 | Extreme value |
|
||||
| test.c:59:3:59:5 | sc6 | $@ flows to here and is used in arithmetic, potentially causing an overflow. | test.c:58:9:58:16 | 127 | Extreme value |
|
||||
| test.c:63:3:63:5 | sc8 | $@ flows to here and is used in arithmetic, potentially causing an underflow. | test.c:62:9:62:16 | - ... | Extreme value |
|
||||
| test.c:75:3:75:5 | sc1 | $@ flows to here and is used in arithmetic, potentially causing an overflow. | test.c:74:9:74:16 | 127 | Extreme value |
|
||||
| test.c:76:3:76:5 | sc1 | $@ flows to here and is used in arithmetic, potentially causing an overflow. | test.c:74:9:74:16 | 127 | Extreme value |
|
||||
| test.c:124:9:124:9 | x | $@ flows to here and is used in arithmetic, potentially causing an overflow. | test.c:118:17:118:23 | 2147483647 | Extreme value |
|
||||
|
||||
@@ -72,8 +72,8 @@ void test_negatives() {
|
||||
signed char sc1, sc2, sc3, sc4, sc5, sc6, sc7, sc8;
|
||||
|
||||
sc1 = CHAR_MAX;
|
||||
sc1 += 0; // GOOD [FALSE POSITIVE]
|
||||
sc1 += -1; // GOOD [FALSE POSITIVE]
|
||||
sc1 += 0; // GOOD
|
||||
sc1 += -1; // GOOD
|
||||
sc2 = CHAR_MIN;
|
||||
sc2 += -1; // BAD [NOT DETECTED]
|
||||
sc3 = CHAR_MIN;
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
| test2.cpp:14:11:14:11 | v | $@ flows to here and is used in arithmetic, potentially causing an overflow. | test2.cpp:25:22:25:23 | & ... | User-provided value |
|
||||
| test2.cpp:14:11:14:11 | v | $@ flows to here and is used in arithmetic, potentially causing an underflow. | test2.cpp:25:22:25:23 | & ... | User-provided value |
|
||||
| test3.c:15:10:15:10 | x | $@ flows to here and is used in arithmetic, potentially causing an overflow. | test3.c:11:15:11:18 | argv | User-provided value |
|
||||
| test3.c:15:14:15:14 | y | $@ flows to here and is used in arithmetic, potentially causing an overflow. | test3.c:11:15:11:18 | argv | User-provided value |
|
||||
| test3.c:15:18:15:18 | z | $@ flows to here and is used in arithmetic, potentially causing an overflow. | test3.c:11:15:11:18 | argv | User-provided value |
|
||||
| test5.cpp:17:6:17:18 | call to getTaintedInt | $@ flows to here and is used in arithmetic, potentially causing an overflow. | test5.cpp:9:7:9:9 | buf | User-provided value |
|
||||
| test5.cpp:19:6:19:6 | y | $@ flows to here and is used in arithmetic, potentially causing an overflow. | test5.cpp:9:7:9:9 | buf | User-provided value |
|
||||
| test5.cpp:19:6:19:6 | y | $@ flows to here and is used in arithmetic, potentially causing an underflow. | test5.cpp:9:7:9:9 | buf | User-provided value |
|
||||
|
||||
@@ -7,3 +7,4 @@
|
||||
| test.cpp:303:11:303:18 | call to try_lock | This lock might not be unlocked or might be locked more times than it is unlocked. |
|
||||
| test.cpp:313:11:313:18 | call to try_lock | This lock might not be unlocked or might be locked more times than it is unlocked. |
|
||||
| test.cpp:442:8:442:17 | call to mutex_lock | This lock might not be unlocked or might be locked more times than it is unlocked. |
|
||||
| test.cpp:482:2:482:19 | call to pthread_mutex_lock | This lock might not be unlocked or might be locked more times than it is unlocked. |
|
||||
|
||||
@@ -445,3 +445,46 @@ bool test_mutex(data_t *data)
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// ---
|
||||
|
||||
struct pthread_mutex
|
||||
{
|
||||
// ...
|
||||
};
|
||||
|
||||
void pthread_mutex_lock(pthread_mutex *m);
|
||||
void pthread_mutex_unlock(pthread_mutex *m);
|
||||
|
||||
class MyClass
|
||||
{
|
||||
public:
|
||||
pthread_mutex lock;
|
||||
};
|
||||
|
||||
bool maybe();
|
||||
|
||||
int test_MyClass_good(MyClass *obj)
|
||||
{
|
||||
pthread_mutex_lock(&obj->lock);
|
||||
|
||||
if (maybe()) {
|
||||
pthread_mutex_unlock(&obj->lock);
|
||||
return -1; // GOOD
|
||||
}
|
||||
|
||||
pthread_mutex_unlock(&obj->lock); // GOOD
|
||||
return 0;
|
||||
}
|
||||
|
||||
int test_MyClass_bad(MyClass *obj)
|
||||
{
|
||||
pthread_mutex_lock(&obj->lock);
|
||||
|
||||
if (maybe()) {
|
||||
return -1; // BAD
|
||||
}
|
||||
|
||||
pthread_mutex_unlock(&obj->lock); // GOOD
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user