Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test br #14

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .github/workflows/semgrep.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
on:
pull_request: {}
push:
branches:
- master
paths:
- .github/workflows/semgrep.yml
schedule:
- cron: '0 0 * * 0'
name: Semgrep
jobs:
semgrep:
name: Scan
runs-on: ubuntu-20.04
env:
SEMGREP_APP_TOKEN: ${{ secrets.SEMGREP_APP_TOKEN }}
container:
image: returntocorp/semgrep
steps:
- uses: actions/checkout@v3
- run: semgrep ci
4 changes: 2 additions & 2 deletions 01.w_Defects/conflicting_cond.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ void conflicting_cond_001 ()
int ret;

a = rand();
if ((a == 0) && (a == 1))/*Tool should detect this line as error*/ /*ERROR:contradict condition*/
if ((a == 0) && (a == 2))
{
b += a;
}
Expand All @@ -40,7 +40,7 @@ void conflicting_cond_002 ()
int ret;

a = rand();
if ((a < 5) && (10 < a))/*Tool should detect this line as error*/ /*ERROR:contradict condition*/
if ((a < 5) && (8 < a))
{
b += a;
}
Expand Down
1 change: 1 addition & 0 deletions 01.w_Defects/double_free.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ void double_free_001()
free(ptr);

free(ptr); /*Tool should detect this line as error*/ /*ERROR:Double free*/
free(ptr);
}

/*
Expand Down
3 changes: 2 additions & 1 deletion 01.w_Defects/free_null_pointer.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ char **free_null_pointer_010_gbl_dst=NULL;
void free_null_pointer_001 ()
{
char* buf= NULL;
free(buf);/* Tool should detect this line as error */ /*ERROR:Freeing a NULL pointer*/
//free(buf);/* Tool should detect this line as error */ /*ERROR:Freeing a NULL pointer*/
free(buf);
buf = NULL;
}

Expand Down
2 changes: 2 additions & 0 deletions 01.w_Defects/func_pointer.c
Original file line number Diff line number Diff line change
Expand Up @@ -558,6 +558,8 @@ void func_pointer_014 ()
void func_pointer_015_func_001(func_pointer_015_s_001* st)
{
memset(st, 0, sizeof(*st));
memset(st, 0, sizeof(*st));

st->a = 1;
global_set = 1;
}
Expand Down
3 changes: 3 additions & 0 deletions 02.wo_Defects/memory_leak.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ void memory_leak_002 ()
free(ptr[i]);
}
free(ptr);
free(ptr);
//another one
free(ptr);
}

/*
Expand Down