Seq Segment Fault.

2009-09-18 Thread Ryan Whited
Here is my code.

#!/bin/bash

echo "Add directions here."

read  URL
read  NUM1
read  NUM2
read  EXT
echo "Please choose a folder name."
read NAM
mkdir $HOME/$NAM
cd $HOME/$NAM


for i in $(seq -w $NUM1 $NUM2); do wget "$URL${i}$EXT"; done

I was testing out my script, and I came across an instance where I had
a large "i" (it started at 00 and went to 99). It
processed for a few minutes (my poor intel atom) and returned with a
"Segmentation fault". From what I know from Assembly, I think this is
a buffer overflow which could allow for malicious code injection.
Please let me know if I can be of further assistance.
-- 
Peace Out and Rock On,
 Ryan Whited




Re: Seq Segment Fault.

2009-09-19 Thread Ryan Whited
Bash version 3.2.48(1)-release (i486-pc-linux-gnu)
Seq (GNU coreutils) 6.10

I apologize for my lack information.

I could be bash, in fact that was my first theory, but I decided to
watch top while I let it run, and Terminal never went over 2% memory
usage. Although it's possible I'm looking in the wrong spot. Bug
reports isn't something I do everyday.

Also, thank you for that bit of code. I'll try it and see if it helps anything.

Again, if I can be of any further assistance. Let me know.

On Fri, Sep 18, 2009 at 7:58 AM, Eric Blake  wrote:
> -BEGIN PGP SIGNED MESSAGE-
> Hash: SHA1
>
> According to Ryan Whited on 9/18/2009 4:38 AM:
>> #!/bin/bash
>> for i in $(seq -w $NUM1 $NUM2)
>
> Are you sure your segfault is in seq, or is it in bash?  You neglected to
> mention which versions you were using:
>
> bash --version
> seq --version
>
> However, it seems to me that your problem is that bash tries to slurp all
> of $() into memory, and seq generated so much data that bash ran out of
> memory (or overflowed its stack).  In other words, it is not a segfault in
> seq, but bash that crashed, and because you exceeded the limits of what
> your machine will support.
>
> - --
> Don't work too hard, make some time for fun as well!
>
> Eric Blake             e...@byu.net
> -BEGIN PGP SIGNATURE-
> Version: GnuPG v1.4.9 (Cygwin)
> Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
>
> iEYEARECAAYFAkqzde8ACgkQ84KuGfSFAYAbHgCgnNr01KRBNuhsC2ifQOEcgx4f
> okQAn2i/cc4inQM46UOq5WeMAsxJnwpj
> =s0aj
> -END PGP SIGNATURE-
>



-- 
Peace Out and Rock On,
 Ryan Whited