bugfindutils - Bugs: bug #3992, xargs leaves stdin open and...

 
 

bug #3992: xargs leaves stdin open and unchanged

Submitted by:  Egmont Koblinger <egmont>
Submitted on:  Mon 16 Jun 2003 10:43:31 AM UTC  
 
Category: xargsSeverity: 3 - Normal
Item Group: NoneStatus: Fixed
Privacy: PublicAssigned to: None
Originator Name: Open/Closed: Closed
Release: NoneFixed Release: 4.2.0

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Sat 03 Jan 2004 10:56:09 PM UTC, comment #1:

This problem is fixed in the CVS code for findutils.
To resolve your problem, you could either wait for the
next official release of findutils, or check out a copy
of the code from the CVS repository for findutils.

James Youngman <jay>
Project Administrator
Mon 16 Jun 2003 10:43:31 AM UTC, original submission:

xargs passes its stdin unchanged to the process
it launches. This way if xargs hasn't read all of
its input yet but has already launched a child
(e.g. -n 1 was given) then this child can cause
xargs itself to malfunction if it starts to read
from this file (which is usually a pipe).

Suggested solution: after forking, before execing,
xargs chould connect /dev/null to file desc 0.
This protetcts the real stdin of xargs from being
read by a malicious child.

How to test the buggy behaviour:

Write a script called foobar:
---begin---
#!/bin/bash
echo "_ $@"
cat
---end---
give exec perms, put in path, and then:
{ for i in `seq 1 10`; do echo $i; sleep 1; done; } | xargs -n 1 foobar

Output should be (and without that sleep the output is):
_1
_2
_3
and so on
_10

However, with that sleep, the output is:
_ 1
4
5
6
7
8
9
10
_ 2
_ 3
which clearly shows that "cat" steals input from
xargs. xargs launches foobar only three times,
though it should do it 10 times.

Tested with version 4.1.7 and 4.1.20.

Egmont Koblinger <egmont>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

CC list is empty

 

Do you think this task is very important?
If so, you can click here to add your encouragement to it.
This task has 0 encouragements so far.

Only logged-in users can vote.

 

Please enter the title of George Orwell's famous dystopian book (it's a date):

 

 

Follow 3 latest changes.

Date Changed By Updated Field Previous Value => Replaced By
Sat 16 Oct 2004 06:15:58 PM UTCjayOpen/ClosedOpen=>Closed
  Fixed ReleaseNone=>4.2.0
Sat 03 Jan 2004 10:56:09 PM UTCjayStatusNone=>Fixed

Back to the top


Powered by Savane 3.1-cleanup1