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

soter_rand(): cast size_t -> int -> size_t unnecessary and potentially lossy #477

Closed
veorq opened this issue May 31, 2019 · 1 comment · Fixed by #485
Closed

soter_rand(): cast size_t -> int -> size_t unnecessary and potentially lossy #477

veorq opened this issue May 31, 2019 · 1 comment · Fixed by #485
Labels
core Themis Core written in C, its packages

Comments

@veorq
Copy link

veorq commented May 31, 2019

In https://github.com/cossacklabs/themis/blob/master/src/soter/boringssl/soter_rand.c#L21, soter_rand() takes a size_t and casts it to int to pass it to RAND_bytes(*, size_t); unlike OpenSSL, boringSSL's RAND_bytes() takes a size_t length and not an int. If more than ~4GB are requested then the call will therefore fail to return the right amount.

Likewise, the OpenSSL counterpart may check for overflows in the (needed) cast https://github.com/cossacklabs/themis/blob/master/src/soter/openssl/soter_rand.c.

@vixentael vixentael added the core Themis Core written in C, its packages label May 31, 2019
@vixentael
Copy link
Contributor

thank you, makes sense :)
will fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Themis Core written in C, its packages
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants