Skip to content

unsafe usage of strcpy #8

@fredo514

Description

@fredo514

In console.c, in console_process() around line 700, static analysis tools pick up an unsafe usage of strcpy. After review, it is probably not a problem as both m_line_buffer and history_line are declared as fixed length arrays of the same size, but even only a disposition complicates the certification of safety-critical systems.

One possible option would be to wipe m_line_buffer with '\0' then using strncpy limited to the length of m_line_buffer, like:

memset(m_line_buffer, '\0', sizeof(m_line_buffer));
strncpy(m_line_buffer, history_line, sizeof(m_line_buffer)-1);

This would ensure that m_line_buffer is always null-terminated no matter what.
However, this requires review as it may conflict with erase_current_line() called before.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions