Skip to content

[noup] zephyr: crypto: fix coverity issue #87

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Qingling-Wu
Copy link

Fix INTEGER_OVERFLOW coverity issue.
crypto_ecdh_set_peerkey:
Check value of the unsigned variable len before decrement. crypto_ec_key_get_subject_public_key/crypto_ec_key_get_ecprivate_key: Check return value of mbedtls_asn1_write_len and mbedtls_asn1_write_tag, if less than zero, return NULL.

Copy link
Member

@jukkar jukkar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes are good. There seems to be two separate issues here, could you split the commit to two pieces and resubmit the PR?

@jukkar
Copy link
Member

jukkar commented May 30, 2025

This also needs a manifest update in zephyr side so that this fix is taken into use, please create a PR in zephyr which updates west.yml file.

@@ -2650,6 +2650,7 @@ struct wpabuf *crypto_ec_key_get_subject_public_key(struct crypto_ec_key *key)
/* algorithm AlgorithmIdentifier */
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and the other
[noup] zephyr: crypto: Fix coverity issue when getting public/private key

Fix INTEGER_OVERFLOW coverity issue.
crypto_ecdh_set_peerkey:
The decrement operator on the unsigned variable len
might result in an underflow.
Check value of the unsigned variable len before decrement.

Signed-off-by: Qingling Wu <qingling.wu@nxp.com>
… key

Fix INTEGER_OVERFLOW coverity issue.
crypto_ec_key_get_subject_public_key/crypto_ec_key_get_ecprivate_key:
tainted_data_return: Called function mbedtls_asn1_write_len,
and a possible return value is known to be less than zero.
overflow: The expression len is considered to have possibly overflowed.

Check return value of mbedtls_asn1_write_len and mbedtls_asn1_write_tag,
if less than zero, return NULL.

Signed-off-by: Qingling Wu <qingling.wu@nxp.com>
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

Successfully merging this pull request may close these issues.

3 participants