helpThe GNU Bourne-Again SHell - Support: sr #108163, Broken shell line handling when...

 
 

sr #108163: Broken shell line handling when using X clipboard as input

Submitted by:  None
Submitted on:  Tue 16 Oct 2012 02:45:02 PM UTC  
 
Category: NonePriority: 5 - Normal
Severity: 4 - ImportantStatus: None
Privacy: PublicAssigned to: None
Originator Email: -unavailable-Open/Closed: Open
Operating System: GNU/Linux

Add a New Comment (Rich MarkupRich Markup):
   

You are not logged in

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

 

Tue 16 Oct 2012 02:45:02 PM UTC, original submission:

Configuration Information:
Machine: x86_64
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='x86_64' -DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='x86_64-unknown-linux-gnu' -DCONF_VENDOR='unknown' -DLOCALEDIR='/usr/share/l
ocale' -DPACKAGE='bash' -DSHELL -DHAVE_CONFIG_H -I. -I. -I./include -I./lib -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector --param=ssp-buffer-size=4 -D_FORTIFY_SOURCE
=2 -DDEFAULT_PATH_VALUE='/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin' -DSTANDARD_UTILS_PATH='/usr/bin:/bin:/usr/sbin:/sbin' -DSYS_BASHRC='/etc/bash.bashrc' -DSYS_BA
SH_LOGOUT='/etc/bash.bash_logout'
uname output: Linux ntb-fedorpiecka 3.5.6-1-ARCH #1 SMP PREEMPT Sun Oct 7 19:30:49 CEST 2012 x86_64 GNU/Linux
Machine Type: x86_64-unknown-linux-gnu

Bash Version: 4.2
Patch Level: 37
Release Status: release

Description:

Long scripts which I paste into xterm (tested with xterm, Gnome Terminal, LXTerminal and Konsole on Gnome, KDE and LXDE) from clipboard are corrupted by BASH.

The problem starts at around 4096 character scripts but is not bound to 4096 and is random. E.g. sometimes 4150 characters work and sometimes 4050 don't.

Repeat-By:

1. Open script1.txt or script2.txt in a text editor in X
2. Select the whole text
3. Copy selected text to clipboard
4. Open terminal window
5. Paste clipboard into the terminal window

Expected result:
a) script1.txt - /tmp/test contains 4096 lines with string test-LINENUMBER on each line where LINENUMBER equals the number of the line

b) script2.txt - /tmp/test contains 128 lines with string "-128abcdefghijlkmnopqrstuvwxyz128-" on the last line

Result in reality:
a) script1.txt - /tmp/test contains randomly selected subset of lines, /tmp/te contains randomly selected subset of lines and bash tries to use /t too and possibly other files with path which is a substring of "/tmp/test"

b) script2.txt - /tmp/test has last N (N seems random) lines corrupted, sometimes bash doesn't register the final EOF correctly and you have to write it by hand (happens with some script lengths)

I've used these generators to prepare the test scripts:

# script1
for i in `seq 1 4096`; do echo "echo test-$i >> /tmp/testfile"; done > /tmp/script1.sh
# end of script1

# script2
echo "cat > /tmp/testfile <<'EOF'" > /tmp/script2.sh
for i in `seq 1 128`; do echo "-${i}abcdefghijlkmnopqrstuvwxyz${i}-"; done >> /tmp/script2.sh
echo EOF >> /tmp/script2.sh
# end of script2

We were able to reproduce the issue on Arch Linux, Linux Mint, Fedora and Debian with bash 4.1 and 4.2 both through an SSH connection and directly.

The issue cannot be reproduced on FreeBSD with bash 3.2.

Anonymous

 

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

Attach File(s):
   
   
Comment:
   

Attached Files
file #26774:  script1.sh added by None (127kB - text/x-sh)
file #26775:  script2.sh added by None (4kB - text/x-sh)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by None (Submitted the item)
  •  

    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 2 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Tue 16 Oct 2012 02:45:02 PM UTCNoneAttached File-=>Added script1.sh, #26774
      Attached File-=>Added script2.sh, #26775

    Back to the top


    Powered by Savane 3.1-cleanup