Skip to content

Function return type with bounds-safe interface is not properly checked in checked scope #302

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

Closed
secure-sw-dev-bot opened this issue Jan 16, 2022 · 2 comments

Comments

@secure-sw-dev-bot
Copy link

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


While testing calloc/malloc header file, unexpected errors happen

In checked scope, function having return type, that is unchecked pointer type with bounds-safe interface, is not properly checked in checked scope.
Since it has proper bounds-safe interface, it SHOULD be considered as checked pointer type but compiler generates an error for this

void * calloc(size_t nmemb, size_t size) : byte_count(nmemb * size);
array_ptr<ptr<node_t>> retval : count(size) = calloc(size, sizeof(ptr<node_t>));
@secure-sw-dev-bot
Copy link
Author

Comment from @wonsubkim:

While testing checkedc-llvm-test-suite, I have found some missing errors

  1. When checking declaration in checked scope, I have missed unexpected type case. Fixed it

  2. When generating function call in checked scope, I have generated implicit cast expression for checked pointer type for FunctionToPointerDecay
    In function declaration having KNR parameters, it has empty parameter types
    For function call for KNR function , SemaBounds generates implicit casting expression from incompatible type.
    For call expression, DO NOT generate checked pointer type of function

  3. In code generation of call instruction (EmitCallArgs), bounds-safe interface has similar problem to interoperation type
    we SHOULD handle same conversion for Sema.GetCheckedCInteropType
    I have also handled unchecked pointer type with bounds-safe interface not also interop type

@secure-sw-dev-bot
Copy link
Author

Comment from @dtarditi:

These issues have been addressed- thanks Wonsub!

For point 2 above, we decided to keep generating an implicit cast to checked pointer type for FunctoinToPointerDecay. We decided to not allow calls to functions declared in the old K&R prototype style in checked scopes. Calls to such functions are treated as no-prototype calls, so there could be mismatches between actual arguments and declared argument.

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