Skip to content
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

Fix #93, Replaces strncpy and strlen #94

Merged
merged 1 commit into from
Jul 2, 2024
Merged

Conversation

chillfig
Copy link
Contributor

@chillfig chillfig commented Jun 4, 2024

Checklist (Please check before submitting)

Describe the contribution

  • Fixes Static analysis issues JSC 2.1 #93. Adds dispositions to line of code in question from static analysis stating why it's safe to keep as-is. Replacing strncpy with snprintf to enhance safety and compliance. Replaces strlen for purposes of verifying non-empty string with memchr.

Testing performed
build, lcov

Expected behavior changes
None

System(s) tested on

  • OS: Ubuntu 22.04

Additional context
snprintf() guarentees null-termination at the line whereas strncpy() does not. This change helps comply with safety assurance.

Depends on nasa/osal#1465

Third party code
N/A

Contributor Info - All information REQUIRED for consideration of pull request
Justin Figueroa, Vantage Systems

@chillfig chillfig self-assigned this Jun 4, 2024
@chillfig chillfig changed the title Fix #93, Replaces strlen and strncpy with CS_strnlen and snprintf Fix #93, Adds JSC 2.1 Static Analysis comments Jun 6, 2024
@chillfig chillfig changed the title Fix #93, Adds JSC 2.1 Static Analysis comments Fix #93, Adds static analysis comments and replace strncpy with snprintf Jun 13, 2024
@chillfig chillfig added the bug label Jun 13, 2024
@chillfig
Copy link
Contributor Author

chillfig commented Jun 13, 2024

CCB 06/13/2024: replace strncpy() with CFE_SB_MessageStringGet(). Snprintf() is slow and not preferable

Edit: Leaving snprintf()

@chillfig
Copy link
Contributor Author

CCB 06/13/2024: replace strncpy() with CFE_SB_MessageStringGet(). Snprintf() is slow and not preferable

Edit: Leaving snprintf()

memchr has now been used to replace strlen

@chillfig chillfig changed the title Fix #93, Adds static analysis comments and replace strncpy with snprintf Fix #93, Adds static analysis comments, replace strncpy and strlen Jun 14, 2024
@chillfig chillfig changed the title Fix #93, Adds static analysis comments, replace strncpy and strlen Fix #93, Replaces strncpy and strlen Jun 17, 2024
@chillfig chillfig mentioned this pull request Jun 20, 2024
2 tasks
This commit addresses issues flagged during static analysis by:
- Replacing strncpy with snprintf to enhance safety and compliance.
- Replacing strlen with OS_strnlen to chance safety and compliance.
@dzbaker
Copy link
Contributor

dzbaker commented Jun 27, 2024

CCB 27 June 2024: Will re-run workflows once osal#1465 is merged in to verify they pass.

@dzbaker dzbaker merged commit c3fd1c2 into nasa:main Jul 2, 2024
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Static analysis issues JSC 2.1
2 participants