GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Fix `binascii.b2a_qp` CRLF boundary check by YangSiJun528 · Pull Request #8358 · RustPython/RustPython

Conversation

@YangSiJun528

@YangSiJun528 YangSiJun528 commented Jul 24, 2026 •
edited by coderabbitai Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor
  • Related to Fuzzing RustPython with fusil #8325 (RUSTPY-0010-binascii-b2a-qp-underflow)
  • This PR follows our AI policy

Summary

  • Prevent binascii.b2a_qp() from panicking when the input starts with \n.
  • Match CPython's boundary check when detecting CRLF line endings.

When the first byte is \n, in_idx remains zero and accessing buf[in_idx - 1] causes an integer underflow.
This change checks in_idx > 0 before accessing the preceding byte.

Testing

  • cargo run -- -c 'import binascii; assert binascii.b2a_qp(b"\n") == b"\n"'
  • cargo run --release -- -m test test_binascii

Before this change, the RustPython command panicked with:

attempt to subtract with overflow

AI assistance

Codex (GPT‑5.6 Sol) was used to investigate and implement this change.
I reviewed and validated all AI-assisted work.

Summary by CodeRabbit

  • Bug Fixes
    • Improved quoted-printable encoding’s carriage-return detection to avoid incorrect line-ending handling near buffer boundaries.
    • Added tighter boundary checks so CR detection only occurs when the previous byte is safely accessible.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@coderabbitai

coderabbitai Bot commented Jul 24, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro Plus

Run ID: 01a403e0-44b8-40bd-96ee-7e4bb61f4faf

📥 Commits

Reviewing files that changed from the base of the PR and between 5c7950f and d73df27.

📒 Files selected for processing (1)
  • crates/stdlib/src/binascii.rs
🚧 Files skipped from review as they are similar to previous changes (1)
  • crates/stdlib/src/binascii.rs

📝 Walkthrough

Walkthrough

b2a_qp now checks that the input index is greater than zero before inspecting the preceding byte when detecting CRLF line endings.

Changes

Quoted-printable encoding

Layer / File(s) Summary
Guard CRLF detection
crates/stdlib/src/binascii.rs
Updates the CRLF detection condition to use in_idx > 0 && in_idx < buflen before accessing buf[in_idx - 1].

Estimated code review effort: 1 (Trivial) | ~2 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title is concise and accurately describes the main fix to the CRLF boundary check in binascii.b2a_qp.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
  • X
  • Mastodon
  • Reddit
  • LinkedIn

Comment @coderabbitai help to get the list of available commands.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@YangSiJun528
Fix b2a_qp CRLF boundary check
d73df27
Assisted-by: Codex:gpt-5.6-sol
@YangSiJun528
YangSiJun528 force-pushed the fix-b2a-qp-crlf-check branch from 5c7950f to d73df27 Compare July 24, 2026 11:50
coderabbitai[bot]
coderabbitai Bot reviewed Jul 24, 2026
View reviewed changes

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@crates/stdlib/src/binascii.rs`:
- Line 507: Preserve the in_idx > 0 guard in the CRLF handling condition to
prevent out-of-bounds indexing, then run cargo fmt --all -- --check with
cargo-fmt available and run Clippy, resolving any warnings before merge.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro Plus

Run ID: 0470bf12-b8f8-45fd-a845-740ac811da17

📥 Commits

Reviewing files that changed from the base of the PR and between 28454cc and 5c7950f.

📒 Files selected for processing (1)
  • crates/stdlib/src/binascii.rs

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread crates/stdlib/src/binascii.rs Resolved

Uh oh!

There was an error while loading. Please reload this page.

@moreal moreal added the z-ca-2026 Tag to track Contribution Academy 2026 label Jul 24, 2026
moreal
moreal approved these changes Jul 24, 2026
View reviewed changes
@youknowone
youknowone merged commit d155c93 into RustPython:main Jul 25, 2026
26 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@YangSiJun528 YangSiJun528 mentioned this pull request Jul 26, 2026
Fuzzing RustPython with fusil #8325
Open
youknowone pushed a commit that referenced this pull request Sep 16, 2026
@YangSiJun528
Fix b2a_qp CRLF boundary check (#8358)
77115b8
Assisted-by: Codex:gpt-5.6-sol
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@coderabbitai coderabbitai[bot] coderabbitai[bot] left review comments
@moreal moreal moreal approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

z-ca-2026 Tag to track Contribution Academy 2026

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@YangSiJun528 @moreal @youknowone
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.