Skip to content

fix(semver): avoid one-past-end index, close #1178#1201

Merged
ken-matsui merged 1 commit intomainfrom
fix-ub-outofbounds-comparator-lexer
Jul 25, 2025
Merged

fix(semver): avoid one-past-end index, close #1178#1201
ken-matsui merged 1 commit intomainfrom
fix-ub-outofbounds-comparator-lexer

Conversation

@ken-matsui
Copy link
Member

No description provided.

@ken-matsui ken-matsui requested a review from Copilot July 25, 2025 16:44
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes an undefined behavior (UB) issue in the ComparatorLexer by replacing direct string array access with a safe curChar() method. The fix prevents out-of-bounds access when checking characters at the current lexer position.

  • Adds a safe curChar() method to VersionLexer that returns '\0' for EOF conditions
  • Replaces all direct parser.lexer.s[parser.lexer.pos] accesses with parser.lexer.curChar() calls

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/Semver.hpp Adds the curChar() method to VersionLexer for safe character access
src/VersionReq.cc Replaces direct array access with safe curChar() method calls

@ken-matsui ken-matsui force-pushed the fix-ub-outofbounds-comparator-lexer branch from ee42aa9 to 7ae310a Compare July 25, 2025 16:47
@ken-matsui ken-matsui changed the title fix: UB out-of-bounds access in ComparatorLexer::next, close #1178 fix(semver): avoid one-past-end index, close #1178 Jul 25, 2025
@ken-matsui ken-matsui enabled auto-merge (squash) July 25, 2025 16:54
@ken-matsui ken-matsui merged commit 45a4edc into main Jul 25, 2025
32 checks passed
@ken-matsui ken-matsui deleted the fix-ub-outofbounds-comparator-lexer branch July 25, 2025 17:18
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.

2 participants