Skip to content

Add ret_size checking in server keystore#302

Open
padelsbach wants to merge 1 commit intowolfSSL:mainfrom
padelsbach:padelsbach/ret-size-server-keystore
Open

Add ret_size checking in server keystore#302
padelsbach wants to merge 1 commit intowolfSSL:mainfrom
padelsbach:padelsbach/ret-size-server-keystore

Conversation

@padelsbach
Copy link
Contributor

Fixes finding 125

@padelsbach padelsbach force-pushed the padelsbach/ret-size-server-keystore branch from 2e17ece to cf37b07 Compare March 17, 2026 19:00
@padelsbach padelsbach marked this pull request as ready for review March 17, 2026 19:48
@padelsbach padelsbach requested a review from bigbrett March 17, 2026 19:48
@padelsbach padelsbach force-pushed the padelsbach/ret-size-server-keystore branch from cf37b07 to 48cdcea Compare March 18, 2026 00:49
@padelsbach padelsbach assigned bigbrett and unassigned padelsbach Mar 18, 2026
@padelsbach padelsbach force-pushed the padelsbach/ret-size-server-keystore branch from 48cdcea to 072967e Compare March 18, 2026 01:05
@padelsbach padelsbach force-pushed the padelsbach/ret-size-server-keystore branch from 072967e to c55e1ad Compare March 19, 2026 19:29
Copy link

@wolfSSL-Fenrir-bot wolfSSL-Fenrir-bot left a comment

Choose a reason for hiding this comment

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

Fenrir Automated Review — PR #302

Scan targets checked: wolfhsm-core-bugs, wolfhsm-src

No new issues found in the changed files. ✅


ret = WH_SERVER_NVM_LOCK(server);
if (ret == WH_ERROR_OK) {
ret = WH_SERVER_NVM_LOCK(server);
Copy link
Contributor

Choose a reason for hiding this comment

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

we want to maintain the following pattern (for ease of inspection, making critical sections as flat and easy to see as possible):

ret = WH_SERVER_NVM_LOCK(server);
if (ret == WH_ERROR_OK) {
    /* do stuff */

    (void)WH_SERVER_NVM_UNLOCK(server);
} /* WH_SERVER_NVM_LOCK() */

Could you ensure this additional error checking still abides by this pattern?

Comment on lines +95 to +96
/* Keystore req_size validation (bug #125) */
WH_TEST_ASSERT(0 == whTest_KeystoreReqSize());
Copy link
Contributor

Choose a reason for hiding this comment

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

this should be macro protected, vs defining a dummy whTest_KeystoreReqSize().

Also pls remove bug# callout in source code.

#endif
}

static int wh_Keystore_TestReqSizeChecking(void)
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm out to lunch as to whether we want to add a unit test for every single bug as this can end up polluting and slowing a test suite, especially given that this one sets up its own harness just to test a few API edge cases.

For example, should every single API test statically allocate a 1MB flash buffer???

I'd like to see us unify the test framework around a few ready-to-use harnesses that unit tests run on top of, depending on what they do and what they need. For example, this function could be refactored to take an initialized server context as a pointer argument, just like the client tests take an initialized client context pointer and then run the tests on top of that initialized context.

That way we could have a whTest_ServerCfg() similar to whTest_ClientCfg() and one of the many server-only tests to be run as part of that would be this one. Or perhaps further subcategorization where this is a "server only API test" where we can put all the various API arg parsing functions. Not sure if you have already done something like that in #313 - havent looked yet.

I think this is fine for now but would like to see this refactored later - pull the server config out into a whTest_ServerCfg() function that does the setup and then runs this test on it.

@bigbrett bigbrett assigned padelsbach and unassigned bigbrett Mar 24, 2026
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