Skip to content

Use of strcpy #2737

Closed
Closed

Description

@brandt-nasa

Static analyzer found two instances of 'strcpy' in cfe. Strcpy does not check bounds and should be replaced with something that does.

Locations:

  • cfe_assert_init | CFE_Assert_OpenLogFile
  • cfe_tbl_internal | CFE_TBL_MarkNameAsModified

Activity

  1. self-assigned this
    on May 20, 2026
  2. added 3 commits that reference this issue on Jun 23, 2026
    1b3a7e0
    3468249
    33bd3b4
  3. elizabash commented on Jun 23, 2026

    @elizabash

    After discussion with Joe and Jose about similar instances where CodeSonar flagged certain functions (like strcpy) for not having bounds checking (though bounds checking was done right before the function) I'm marking on our CodeSonar website to ignore these lines.

    Background Info Into Why This Became An Issue
    CodeSonar flagged the following error: BADFUNC.BO.STRCPY : Use of strcpy
    CodeSonar Summary: A use of strcpy() or a similar function (see full list below), which are vulnerable to buffer overflows.
    CodeSonar Resolution Suggestion: Use a function that does bounds checking, such as strncpy(), StrCbCopy(), or StrCchCopy().

    The issue seems to be a concern over buffer overflow. However, in this case, though strcpy itself isn't bounds checking, there is bounds checking being done immediately beforehand.

    Discussion about CodeSonar and this issue
    Today (6/23/26) during our cFS + DARPA meeting, we discussed this issue and pull request. The PR #2768 included two comments to tell CodeSonar to ignore the line. This comment needs to be on every individual line that needs to be ignored.
    We decided during the meeting that instead of having a million comments everywhere telling CodeSonar to ignore certain lines, we'll instead log into CodeSonar and tell it to ignore false positives from there. That way, if the project decides to stop using CodeSonar in favor of using a different static analyzer, we won't have a bunch of useless comments everywhere in the code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions