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

Catch buffer overflows in structures #140

Open
arthaud opened this issue Jul 11, 2019 · 2 comments
Open

Catch buffer overflows in structures #140

arthaud opened this issue Jul 11, 2019 · 2 comments
Labels
C-feature-request Category: Feature Request L-c Language: C P-medium Priority: Medium

Comments

@arthaud
Copy link
Member

arthaud commented Jul 11, 2019

The current analysis cannot catch a buffer overflow in a structure.

For instance:

#include <ikos/analyzer/intrinsic.h>

typedef struct {
    int tab[10];
    int x;
} Struct;

int main() {
    Struct s;
    s.tab[10] = 1; // overflow on tab, writes on x
    __ikos_assert(s.x == 1);
    return 0;
}

The analyzer only checks that the memory write is within the structure, so it is considered safe.

The analyzer will actually know that s.x is 1, so we could say that the analysis is somewhat sound regarding the memory model.

To fix this, we should investigate the inbounds flag of the LLVM getelementptr instruction.

See:

@arthaud arthaud added C-bug Category: Bug C-feature-request Category: Feature Request L-c Language: C P-medium Priority: Medium labels Jul 11, 2019
@ivanperez-keera
Copy link
Collaborator

Is this a bug or a feature request?

@ivanperez-keera
Copy link
Collaborator

My understanding is that this is not a bug. I'm switching labels accordingly. If you disagree, please revert the change.

@ivanperez-keera ivanperez-keera removed the C-bug Category: Bug label Dec 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-feature-request Category: Feature Request L-c Language: C P-medium Priority: Medium
Projects
None yet
Development

No branches or pull requests

2 participants