Skip to content

fix: bound lexicographic permutation input - #1594

Open
wjc2821296948 wants to merge 1 commit into
TheAlgorithms:masterfrom
wjc2821296948:fix-lexicographic-input-bounds-960
Open

wjc2821296948 wants to merge 1 commit into
TheAlgorithms:masterfrom
wjc2821296948:fix-lexicographic-input-bounds-960

Conversation

@wjc2821296948

Copy link
Copy Markdown

Fix the input buffer handling in misc/lexicographic_permutations.c.

The program allocated exactly n bytes for an input of up to n characters, leaving no room for the terminating null byte, and used an unbounded %s conversion. The buffer now reserves n + 1 bytes, checks allocation/input failures, and constructs a bounded %ns format from the validated input size.

Compiled with C11 warnings enabled and verified with a 3-character permutation input.

Refs #960

Co-Authored-By: chaogeshuodiannao <chaogeshuodiannao@users.noreply.github.com>

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant