Skip to content

Buffer overflow #3

@ai-and-i

Description

@ai-and-i

Hi, I think this line can cause buffer overflow:

because index can equal to bufferSize after this:

} else if (index < bufferSize) {
buffer[index] = ch;
index++;

I suggest to fix it by replacing else if (index < bufferSize) with else if (index < bufferSize - 1), ensuring that one byte is always left for the zero termination character.

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