Skip to content

Buffer overflow #3

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.

Activity

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

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