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

Is this feedback correct? #1833

Closed
wbhqmzl opened this issue Apr 22, 2024 · 0 comments
Closed

Is this feedback correct? #1833

wbhqmzl opened this issue Apr 22, 2024 · 0 comments

Comments

@wbhqmzl
Copy link

wbhqmzl commented Apr 22, 2024

#define MAX_LEN (16)
void test(const unsigned char *additional, size_t len, size_t nonce_len, size_t entropy_len)
{
        unsigned char seed[MAX_LEN];
        size_t        seedlen = 0;
 
        if(entropy_len > MAX_LEN) 
            return;
        if(nonce_len > MAX_LEN - entropy_len) 
            return;
        if(len > MAX_LEN - entropy_len - nonce_len) 
            return;
 
        seedlen +=  entropy_len;
        if(nonce_len != 0)
                seedlen += nonce_len;
        if(additional != NULL && len != 0){
                memcpy(seed + seedlen, additional, len);
                seedlen += len;
        }
}
int main()
{
        unsigned char arr[20] = {0};
        test(arr, 8, 0, 5);
        return 0;
}
Infer:31: error: Buffer Overrun L2
Offset added: [13, 24] (⇐ [5, 16] + 8) Size: 16 by call to test.
29. {
30. unsigned char arr[20] = {0};
31. test(arr, 8, 0, 5);
^
32. return 0;
33. }
A call to the main function may not cause the array of the called function to go out of bounds

@wbhqmzl wbhqmzl changed the title false positive Is this feedback correct? Apr 22, 2024
@wbhqmzl wbhqmzl closed this as completed Apr 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant