Skip to content

fix(builtins): cap AWK output buffer size to prevent memory exhaustion#1055

Merged
chaliy merged 3 commits intomainfrom
fix/issue-987-awk-output-limit
Apr 4, 2026
Merged

fix(builtins): cap AWK output buffer size to prevent memory exhaustion#1055
chaliy merged 3 commits intomainfrom
fix/issue-987-awk-output-limit

Conversation

@chaliy
Copy link
Copy Markdown
Contributor

@chaliy chaliy commented Apr 3, 2026

Summary

  • Add MAX_AWK_OUTPUT_BYTES constant (10MB) to cap total AWK output
  • write_output() now checks total across stdout, stderr, file_outputs, and file_appends
  • Returns error with exit code 2 when limit exceeded
  • Prevents OOM from awk '{for(i=0;i<100000;i++) printf "%10000s\n", "x"}'

Test plan

  • Stdout overflow caught with exit code 2
  • Normal output under limit works correctly
  • File redirect overflow also caught
  • All existing AWK tests pass

Closes #987

@chaliy chaliy merged commit 7e31915 into main Apr 4, 2026
27 checks passed
@chaliy chaliy deleted the fix/issue-987-awk-output-limit branch April 4, 2026 01:15
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.

AWK output buffer grows without bound, enabling memory exhaustion

1 participant