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

C++: BufferAccess shouldn't consider expressions in sizeof #12576

Open
gsingh93 opened this issue Mar 17, 2023 · 0 comments
Open

C++: BufferAccess shouldn't consider expressions in sizeof #12576

gsingh93 opened this issue Mar 17, 2023 · 0 comments
Labels
question Further information is requested

Comments

@gsingh93
Copy link
Contributor

gsingh93 commented Mar 17, 2023

I have some code like this:

unsigned long foo() {
  char buf[1];
  return sizeof(buf[0]);
}

My understanding is that buf[0] is actually not accessing the buffer, sizeof will just get the sizeof the type without any memory access. Yet this query still returns it as a result:

import cpp
import semmle.code.cpp.security.BufferAccess

from BufferAccess ba
select ba

Is this intended? It results in a few false positives in my queries.

@gsingh93 gsingh93 added the question Further information is requested label Mar 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

1 participant