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

Static analyser: NULL pointer passing. #69

Closed
0xceed opened this issue Jun 30, 2021 · 3 comments
Closed

Static analyser: NULL pointer passing. #69

0xceed opened this issue Jun 30, 2021 · 3 comments

Comments

@0xceed
Copy link

0xceed commented Jun 30, 2021

File: arg_dstr.c
Line: 307.

See screenshot attached. Haven't checked if any other static analyser catches this, but still.

Screenshot 2021-07-01 at 01 31 49

@0xceed
Copy link
Author

0xceed commented Jun 30, 2021

Also, lib version is 3.2.1

@tomghuang
Copy link
Contributor

Hi @0xceed, I've checked the code and your screenshot, and found that the static analysis tool is wrong.

The static analysis tool assumes that total_space could be < ds->append_data_size. However, it is impossible. When ds->append_data_size > 500, we not only set ds->append_data to NULL, but also set ds->append_data_size to 0. Therefore, total_space should always be >= ds->append_data_size.

        if (ds->append_data_size > 500) {
            xfree(ds->append_data);
            ds->append_data = NULL;
            ds->append_data_size = 0;
        }

You may need to use some mechanism to skip this logic error in the static analysis tool. Thanks.

@0xceed
Copy link
Author

0xceed commented Jul 1, 2021

Thank you a bunch, sure thing, I haven't checked it's correctness; just wondered if this real bug.

@0xceed 0xceed closed this as completed Jul 1, 2021
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

2 participants