Skip to content

Commit eedcb01

Browse files
authored
Add files via upload
1 parent b10bdf1 commit eedcb01

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
| test.c:13:10:13:21 | call to tmpFunction1 | This expression may have undefined behavior. |
2+
| test.c:13:30:13:41 | call to tmpFunction2 | This expression may have undefined behavior. |
3+
| test.c:16:15:16:20 | ... ++ | This expression may have undefined behavior. |
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
experimental/Security/CWE/CWE-758/UndefinedOrImplementationDefinedBehavior.ql
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
char tmpFunction1(char * buf)
2+
{
3+
buf[1]=buf[1] + buf[2] + buf[3];
4+
return buf[1];
5+
}
6+
char tmpFunction2(char * buf)
7+
{
8+
buf[2]=buf[1] + buf[2] + buf[3];
9+
return buf[2];
10+
}
11+
void workFunction_0(char *s, char * buf) {
12+
int intA;
13+
intA = tmpFunction1(buf) + tmpFunction2(buf); // BAD
14+
intA = tmpFunction1(buf); //GOOD
15+
intA += tmpFunction2(buf); // GOOD
16+
buf[intA] = intA++; // BAD
17+
intA++;
18+
buf[intA] = intA; // GOOD
19+
}

0 commit comments

Comments
 (0)