Skip to content

Commit b899229

Browse files
authored
Add files via upload
1 parent 9ae503a commit b899229

3 files changed

Lines changed: 54 additions & 0 deletions

File tree

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
| test.c:13:3:13:24 | ... = ... | use a different method to calculate the length. |
2+
| test.c:14:3:14:40 | ... = ... | use a different method to calculate the length. |
3+
| test.c:15:3:15:40 | ... = ... | use a different method to calculate the length. |
4+
| test.c:16:3:16:44 | ... = ... | use a different method to calculate the length. |
5+
| test.c:17:3:17:44 | ... = ... | use a different method to calculate the length. |
6+
| test.c:18:3:18:48 | ... = ... | use a different method to calculate the length. |
7+
| test.c:19:3:19:48 | ... = ... | use a different method to calculate the length. |
8+
| test.c:20:3:20:50 | ... = ... | use a different method to calculate the length. |
9+
| test.c:21:3:21:50 | ... = ... | use a different method to calculate the length. |
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
experimental/Security/CWE/CWE-788/AccessOfMemoryLocationAfterEndOfBufferUsingStrlen.ql
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
struct buffers
2+
{
3+
unsigned char buff1[50];
4+
unsigned char *buff2;
5+
} globalBuff1,*globalBuff2,globalBuff1_c,*globalBuff2_c;
6+
7+
8+
void badFunc0(){
9+
unsigned char buff1[12];
10+
struct buffers buffAll;
11+
struct buffers * buffAll1;
12+
13+
buff1[strlen(buff1)]=0;
14+
buffAll.buff1[strlen(buffAll.buff1)]=0;
15+
buffAll.buff2[strlen(buffAll.buff2)]=0;
16+
buffAll1->buff1[strlen(buffAll1->buff1)]=0;
17+
buffAll1->buff2[strlen(buffAll1->buff2)]=0;
18+
globalBuff1.buff1[strlen(globalBuff1.buff1)]=0;
19+
globalBuff1.buff2[strlen(globalBuff1.buff2)]=0;
20+
globalBuff2->buff1[strlen(globalBuff2->buff1)]=0;
21+
globalBuff2->buff2[strlen(globalBuff2->buff2)]=0;
22+
}
23+
void noBadFunc0(){
24+
unsigned char buff1[12],buff1_c[12];
25+
struct buffers buffAll,buffAll_c;
26+
struct buffers * buffAll1,*buffAll1_c;
27+
28+
buff1[strlen(buff1_c)]=0;
29+
buffAll.buff1[strlen(buffAll_c.buff1)]=0;
30+
buffAll.buff2[strlen(buffAll.buff1)]=0;
31+
buffAll1->buff1[strlen(buffAll1_c->buff1)]=0;
32+
buffAll1->buff2[strlen(buffAll1->buff1)]=0;
33+
globalBuff1.buff1[strlen(globalBuff1_c.buff1)]=0;
34+
globalBuff1.buff2[strlen(globalBuff1.buff1)]=0;
35+
globalBuff2->buff1[strlen(globalBuff2_c->buff1)]=0;
36+
globalBuff2->buff2[strlen(globalBuff2->buff1)]=0;
37+
}
38+
void goodFunc0(){
39+
unsigned char buffer[12];
40+
int i;
41+
for(i = 0; i < 6; i++)
42+
buffer[i] = 'A';
43+
buffer[i]=0;
44+
}

0 commit comments

Comments
 (0)