Skip to content

Coverity Warnings Fix#8891

Closed
JeremiahM37 wants to merge 17 commits intowolfSSL:masterfrom
JeremiahM37:coverityTest
Closed

Coverity Warnings Fix#8891
JeremiahM37 wants to merge 17 commits intowolfSSL:masterfrom
JeremiahM37:coverityTest

Conversation

@JeremiahM37
Copy link
Contributor

@JeremiahM37 JeremiahM37 commented Jun 17, 2025

Description

Potential fixes for the Coverity warnings addressed in the support ticket. So far, I think I have fixes for the mixed Enums issue in hmac.c as well as the unused value warnings. The undefined min warning can be ignored since there is a fallback it.
Fixes zd#20029

Testing

How did you test?

Checklist

  • added tests
  • updated/added doxygen
  • updated appropriate READMEs
  • Updated manual and documentation

@JeremiahM37 JeremiahM37 self-assigned this Jun 18, 2025

/* free temporary buffer */
XFREE(buf, pkcs12->heap, DYNAMIC_TYPE_PKCS);
buf = NULL;
Copy link
Contributor

Choose a reason for hiding this comment

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

Clang-tidy is very unhappy with this change. Please find a better way to fix:

[clang-tidy-defaults] [7 of 7] [wolfssl]
    configure...   real 0m5.920s  user 0m4.165s  sys 0m2.072s
    build.../tmp/workspace/PRB-multi-test-script/wolfssl/wolfcrypt/src/pkcs12.c:1718:9: warning: Attempt to free released memory [clang-analyzer-unix.Malloc]
XFREE(buf, pkcs12->heap, DYNAMIC_TYPE_PKCS);
^```

int ret = 0;

switch (type) {
switch ((int)type) {
Copy link
Contributor

Choose a reason for hiding this comment

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

type is already an int, so this change isn't doing anything. Please revert.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

233861-hmac c

Coverity is giving this warning due to inferred misuse of enums. I brough up potential solutions with Kareem, either changing the function declaration from (int type) to (enum wc_HashType type) or just casting type to int, and he suggested that simply casting to int would likely work and be the easier solution. Should I go try converting them all to enum wc_hashType and change WC_MD5 to WC_HASH_TYPE_MD5 in the function declaration or try to find a different solution entirely?

Copy link
Contributor

Choose a reason for hiding this comment

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

The fix is to cast to enum wc_HashType

@JeremiahM37 JeremiahM37 reopened this Jun 18, 2025
@JeremiahM37 JeremiahM37 marked this pull request as draft June 18, 2025 22:34
switch ((enum wc_HashType)type) {
#ifndef WOLFSSL_NO_SHA224
case WC_HASH_TYPE_SHA224:
switch (type) {
Copy link
Contributor

Choose a reason for hiding this comment

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

The old code was fine. I think you'll have issues with some of the older FIPS using this technique. The warnings reported are harmless and have to do with a mix of us passing int type and wc_HashType type. The important thing to identify is if you are actually comparing the same types, since we also have OID's and NID's.

JacobBarthelmeh and others added 16 commits June 20, 2025 12:01
Use sb instruction instead of isb if available.
…lied seed with the CPU ID of each DRBG, to avoid duplicate states;

wolfcrypt/src/random.c: in Hash_DRBG_Generate(), always put digest[] on the stack even in WOLFSSL_SMALL_STACK configuration (it's only 32 bytes);

configure.ac: default smallstackcache on when linuxkm-defaults.
…km_drbg_seed(), check retval from wc_LockMutex().

wolfcrypt/src/random.c: in Hash_DRBG_Generate(), restore smallstack path for digest[], but use non-smallstack path for WOLFSSL_LINUXKM.
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.

8 participants