Skip to content

fix: restrict octal parsing to valid octal digits#59

Draft
toddr-bot wants to merge 1 commit intomainfrom
koan.toddr.bot/fix-octal-parse-char-value
Draft

fix: restrict octal parsing to valid octal digits#59
toddr-bot wants to merge 1 commit intomainfrom
koan.toddr.bot/fix-octal-parse-char-value

Conversation

@toddr-bot
Copy link
Copy Markdown
Collaborator

@toddr-bot toddr-bot commented Apr 6, 2026

What

Fix _parse_char_value silently returning 0 for values like "08" and "09".

Why

The octal regex /^0(\d+)$/ matched any digits after a leading zero, including
8 and 9. Perl's oct() rejects these as illegal octal digits and returns 0 —
meaning stty intr 08 would disable the interrupt character instead of
setting it to 8. On Linux where _POSIX_VDISABLE is 0, this is especially
dangerous: you silently lose the ability to interrupt processes.

How

Narrowed the octal regex to /^0([0-7]+)$/. Values containing 8 or 9 now
fall through to the decimal integer path and return the expected value.

Testing

Added 3 test cases (08, 09, 019). Full suite: 148 tests pass.

🤖 Generated with Claude Code


Quality Report

Changes: 2 files changed, 9 insertions(+), 2 deletions(-)

Code scan: clean

Tests: passed (OK)

Branch hygiene: 1 issue(s)

  • Branch is not pushed to remote

Generated by Kōan post-mission quality pipeline

Values like "08" and "09" matched the octal regex /^0(\d+)$/ but
contained digits invalid in octal (8, 9).  Perl's oct() silently
returned 0 for these, so `stty intr 08` would disable the interrupt
character instead of setting it to 8.

Narrow the regex to /^0([0-7]+)$/ so inputs with 8/9 fall through
to the decimal path and produce the expected value.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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