Bug 815314

Summary: bash range expansion with large numbers causes DoS
Product: [Fedora] Fedora Reporter: ojab <bugzilla.redhat.com>
Component: bashAssignee: Roman Rakus <rrakus>
Status: CLOSED NOTABUG QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 16CC: maxamillion, rrakus, tsmetana
Target Milestone: ---   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2012-04-23 12:53:39 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description ojab 2012-04-23 10:45:00 UTC
Description of problem:
I'm using bash for loops with large-number ranges like {99450..99459} and one time typo led me to {994450..99459}, which led me to unresponsive system till OOM-killer.

Version-Release number of selected component (if applicable):
Name        : bash
Arch        : x86_64
Version     : 4.2.24
Release     : 1.fc16


Steps to Reproduce:
1. for i in {1..9999999}; do echo ${i} ; done
  
Actual results:
bash that cannot be killed via Ctrl-C/`kill` (`kill -9` works) and eats a LOT of RAM.

Expected results:
Expansion works or throws error (`too large number` or something like)

Additional info:
Also reproducible on Centos-5.8 x86_64.

Comment 1 Roman Rakus 2012-04-23 12:53:39 UTC
This is expected behaviour. It was several times discussed upstream. You should use c-style for cycle in this case.