Skip to content

Inconsistencies with unused void* inside checked scopes #749

Open
@secure-sw-dev-bot

Description

@secure-sw-dev-bot

This issue was copied from checkedc/checkedc-clang#753


The following code does not pass the checker due to the presence of void *w in the checked block:

int main(int argc, _Ptr<_Ptr<char>> argv) _Checked{
int x = 3;
int i;
_Ptr<int> p = NULL;
p = &x;
void *w;

for(i = 0; i<10; i++) _Checked{
    *p += i;
}
return *p;
}

However, if the void* is inside a struct then it will pass:

typedef struct {
int count;
void* arr;
} Ex;

int main(int argc, _Ptr<_Ptr<char>> argv) _Checked{
int x = 3;
int i;
_Ptr<int> p = NULL;
p = &x;
Ex e;

for(i = 0; i<10; i++) _Checked{
    *p += i;
}
return *p;
}

If the void* inside the struct is used then it is rejected:

typedef struct {
int count;
void* arr;
} Ex;

int main(int argc, _Ptr<_Ptr<char>> argv) _Checked{
int x = 3;
int i;
_Ptr<int> p = NULL;
p = &x;
Ex e;
e.arr = p;
for(i = 0; i<10; i++) _Checked{
    *p += i;
}
return *p;
}

This also applies to functions with void * passed as parameters, for ex: the following function passes the checker:

int foo(void *w) _Checked{
return NULL;
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions