Skip to content

Return SPI out of range error from sa_create - #547

Open
Hashim1999164 wants to merge 2 commits into
nasa:devfrom
Hashim1999164:fix/sa-create-out-of-range-spi
Open

Hashim1999164 wants to merge 2 commits into
nasa:devfrom
Hashim1999164:fix/sa-create-out-of-range-spi

Conversation

@Hashim1999164

@Hashim1999164 Hashim1999164 commented Sep 18, 2026 •

Copy link
Copy Markdown

Summary

sa_create treated an out of range SPI as success. The else branch only printed under DEBUG and never set status, so it returned CRYPTO_LIB_SUCCESS even though no SA was created.

This sets CRYPTO_LIB_ERR_SPI_INDEX_OOB on that path, matching the other SA helpers in the same file.

Closes #545

Test plan

  • Call SA Create with an SPI >= NUM_SA and confirm the status is CRYPTO_LIB_ERR_SPI_INDEX_OOB
  • Confirm a valid SPI create path still returns success

The out of range branch only printed under DEBUG and left status at
CRYPTO_LIB_SUCCESS, so SA Create looked successful to the ground
segment when no SA was created. Set CRYPTO_LIB_ERR_SPI_INDEX_OOB the
same way the other SA helpers do.

Closes nasa#545
@Hashim1999164

Copy link
Copy Markdown
Author

heads up, i still need to send in the CryptoLib individual CLA pdf to the emails in the readme. will get that over. the code change itself is just the SPI OOB status return

@sylvesterkaczmarek sylvesterkaczmarek left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This changes a previously silent success into the intended SPI-out-of-range error, but there is no regression test in the PR and the two test-plan boxes are still unchecked. Please add a test that sends spi >= NUM_SA and asserts CRYPTO_LIB_ERR_SPI_INDEX_OOB, plus a valid-SPI case to keep the success path covered.

@Hashim1999164

Copy link
Copy Markdown
Author

@sylvesterkaczmarek fair point. added a unit test in ut_tc_process that hits spi >= NUM_SA for the oob error and a valid spi=1 create for the success path. checkboxes updated too

@Hashim1999164

Copy link
Copy Markdown
Author

yo the CLA for this one is that pdf form in docs/CryptoLib_Indv_CLA.pdf that has to get emailed to gsfc-softwarerequest@mail.nasa.gov with Justin.R.Morris@nasa.gov cc'd. i cant finish that part from here since it needs the signed pdf mailed. code side + the regression test are already on the branch tho

@sylvesterkaczmarek sylvesterkaczmarek left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Rechecked a283264. sa_create now returns CRYPTO_LIB_ERR_SPI_INDEX_OOB when spi >= NUM_SA, and the new regression exercises that exact boundary plus a valid spi=1 success path. That resolves the missing-test concern I raised.

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.

🐛 [BUG] - sa_create Silently Returns Success for an Out-of-Range SPI

2 participants