Skip to content

Sed branch loop limit silently truncates output without warning #1005

@chaliy

Description

@chaliy

Summary

The sed branch/label execution loop has a limit of 1000 iterations per line. When exceeded, execution silently stops without error or warning. Legitimate sed scripts using branches (counters, complex transformations) produce incorrect output silently — a data integrity issue.

Severity: Low
Category: Silent Data Corruption / Correctness

Affected Files

  • crates/bashkit/src/builtins/sed.rs lines 823-826

Steps to Reproduce

# Legitimate sed loop needing >1000 iterations
printf 'a' | sed ':loop; s/a/aa/; /.\{2000\}/!b loop'
# Silently stops at 1000 iterations, producing wrong output length

Impact

Silent data corruption. Scripts depending on sed loops produce incorrect results without any warning.

Acceptance Criteria

  • Emit stderr warning when branch iteration limit is hit
  • Or: make the limit configurable
  • Test: Hitting the limit produces a warning on stderr
  • Test: Normal sed scripts under 1000 iterations work unchanged

Metadata

Metadata

Assignees

No one assigned

    Labels

    securitySecurity vulnerability or hardening

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions