-
Notifications
You must be signed in to change notification settings - Fork 11
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
Added Compliant and NonCompliant DL cases for C language #6
base: main
Are you sure you want to change the base?
Conversation
|
||
int compliant() { | ||
//Compliant : using `strsep_s()` can leads to crashes or security issues. | ||
char *static_str = "message,token"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update the example here. Some mismatch.
#include <stdlib.h> | ||
|
||
void noncompliant() { | ||
//NonCompliant : using `strtok()` tokenises strings safely via pointer without altering the original and also supports thread-safe parsing. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some mismatch between compliant
and non compliant
int compliant(){ | ||
//Compliant : Ensuring proper allocation and deallocation procedures. | ||
int initial = 1000; | ||
struct data *data = malloc(sizeof(*data)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you cal the variable data_pointer
So,
struct data *data_ptr = malloc(sizeof(*data_ptr));
|
||
int noncompliant() { | ||
//NonCompliant : Avoid using `sscanf()` for number conversions. | ||
const char *float_str = "3.1415926535897932384626433832"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can the length of the float be changed "3.14159"
should be enough
#include <stdio.h> | ||
|
||
void compliant() { | ||
//Compliant : Using `scanf()` explicitly null terminate buffer. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comment is not clear
Added non compliant and compliant samples for C detectors.
Note: All the test cases have 100% recall and precision.