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
provider: return error if buf too small when get ec pubkey param #20890
Conversation
20a10b0
to
910c9f4
Compare
Please add a test for these conditions...
|
910c9f4
to
99e6d7d
Compare
Thanks for review, patch updated. |
test/evp_extra_test.c
Outdated
if (!TEST_int_eq(EVP_PKEY_get_octet_string_param(params_and_pub, | ||
OSSL_PKEY_PARAM_ENCODED_PUBLIC_KEY, | ||
buffer, 10, &len), 0) | ||
|| !TEST_int_eq(len, 65)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test is not right,,,
If the above test was to magically pass (which it wont), then we would expect the returned len <= 10 if we passed in a max buffer of 10. If it returned 65 it would indicate we just trashed the buffer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test is not right,,, If the above test was to magically pass (which it wont), then we would expect the returned len <= 10 if we passed in a max buffer of 10. If it returned 65 it would indicate we just trashed the buffer.
This case means if we input a too-short buffer, this function will not change the value of len
(which was set to 65 in the previous testcase).
It's really confusing here, maybe we can set the value of len
to 0 before this test.
int EVP_PKEY_get_octet_string_param()
{
OSSL_PARAM params[2];
int ret1 = 0, ret2 = 0;
......
/* return 0 here */
if ((ret1 = EVP_PKEY_get_params(pkey, params)))
ret2 = OSSL_PARAM_modified(params);
/* will not change out_len here */
if (ret2 && out_len != NULL)
*out_len = params[0].return_size;
return ret1 && ret2;
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do NOT think we should check the return size is assigned in case of failure. IMO this is implementation-defined behavior.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds reasonable.
There is no reason for the caller to check out_len
if the function has returned an error value
99e6d7d
to
a025d50
Compare
Thanks for review, patch updated. |
FIX: openssl#20889 Should check buffer size when get ec pubkey param, if buffer is not NULL and size too-small, return 0 as error code. Signed-off-by: Yi Li <yi1.li@intel.com>
a025d50
to
01a84ab
Compare
@paulidale please reconfirm |
This pull request is ready to merge |
Merged to master, 3.1, and 3.0 branches. Thank you for your contribution. |
Fixes #20889 There was an incorrect value passed to EC_POINT_point2oct() for the buffer size of the param passed-in. Added testcases. Signed-off-by: Yi Li <yi1.li@intel.com> Reviewed-by: Paul Dale <pauli@openssl.org> Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from #20890) (cherry picked from commit 9107087)
Fixes #20889 There was an incorrect value passed to EC_POINT_point2oct() for the buffer size of the param passed-in. Added testcases. Signed-off-by: Yi Li <yi1.li@intel.com> Reviewed-by: Paul Dale <pauli@openssl.org> Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from #20890) (cherry picked from commit 9107087)
FIX: #20889
Should check buffer size first when get ec pubkey param, if buffer size too-small, return -1 as error code.
Checklist