Skip to content

Fix undefined behaviors in strings.c #263

@ncruces

Description

@ncruces

strncmp can currently access beyond the end of string, as it assumes it can always read n chars.

memchr does not respect this sentence in the standard:

The implementation shall behave as if it reads the characters sequentially and stops as soon as a matching character is found.

For both the problem is intrinsically the same: they attempt to tolerate unaligned access, which may cross a page boundary into "unmapped" memory (or actually wrap around the whole 4GB).

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions