From bkoenig@alpha-tierchen.de  Mon Dec 17 16:41:53 2007
Return-Path: <bkoenig@alpha-tierchen.de>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 476AA16A55A
	for <FreeBSD-gnats-submit@freebsd.org>; Mon, 17 Dec 2007 16:41:53 +0000 (UTC)
	(envelope-from bkoenig@alpha-tierchen.de)
Received: from mail.liberty-hosting.de (mail.smartterra.de [195.225.132.203])
	by mx1.freebsd.org (Postfix) with ESMTP id 1830D13C458
	for <FreeBSD-gnats-submit@freebsd.org>; Mon, 17 Dec 2007 16:41:52 +0000 (UTC)
	(envelope-from bkoenig@alpha-tierchen.de)
Received: from home.alpha-tierchen.de (port-212-202-40-215.dynamic.qsc.de [212.202.40.215])
	by mail.liberty-hosting.de (Postfix) with ESMTP id 226F33E95F2
	for <FreeBSD-gnats-submit@freebsd.org>; Mon, 17 Dec 2007 17:41:41 +0100 (CET)
Received: by home.alpha-tierchen.de (Postfix, from userid 2000)
	id 0E2C428689; Mon, 17 Dec 2007 17:40:20 +0100 (CET)
Message-Id: <20071217164020.0E2C428689@home.alpha-tierchen.de>
Date: Mon, 17 Dec 2007 17:40:20 +0100 (CET)
From: Bjoern Koenig <bkoenig@alpha-tierchen.de>
Reply-To: Bjoern Koenig <bkoenig@alpha-tierchen.de>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: shar sometimes creates broken archives
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         118782
>Category:       bin
>Synopsis:       [patch] shar(1) sometimes creates broken archives
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    remko
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Dec 17 16:50:01 UTC 2007
>Closed-Date:    Tue Jun 17 19:11:01 UTC 2008
>Last-Modified:  Tue Jun 17 19:20:01 UTC 2008
>Originator:     Bjoern Koenig
>Release:        affects all releases
>Organization:
>Environment:


	
>Description:
	The shar(1) utility creates EOF markers from the pathname
	of a file. The length EOF markers are restricted to 79
	bytes by sh(1). If the length of the EOF marker created
	by shar exceeds this limit then you'll get an error while
	extracting the archive:

		Syntax error: Illegal eof marker for << redirection
	
>How-To-Repeat:
	$ mkdir -p this/is/a/long/path/name/for/demonstration/of/a/bug
	$ echo test > this/is/a/long/path/name/for/demonstration/of/a/bug/and-this-is-a-filename
	$ shar `find this -type f` > archive
	$ sh archive
	x - this/is/a/long/path/name/for/demonstration/of/a/bug/and-this-is-a-filename
	archive: 11: Syntax error: Illegal eof marker for << redirection

>Fix:

	I do not provide a patch yet since there are several solutions which
	should be discussed:

	a) increase EOFMARKLEN in src/bin/sh/parser.c
		This won't actually solve the problem, but shifts it away if
		EOFMARKLEN is reasonable large enough.

	b) change sh that it doesn't restrict length of the EOF marker
		This is possible and in my opinion most elegant.

	c) change shar to respect the limitation of sh
		This is almost unjustifiable, because the shar utility is an
		incredibly simple shell script and this solution requires to
		add complex code.

	d) add a small notice to the BUGS section of shar's manpage
		Suggest also to use another shell code interpreter
		to extract the archive, e.g. bash.

	Choose one!
	
>Release-Note:
>Audit-Trail:

From: Jaakko Heinonen <jh@saunalahti.fi>
To: bkoenig@alpha-tierchen.de
Cc: bug-followup@FreeBSD.org
Subject: Re: bin/118782: shar(1) sometimes creates broken archives
Date: Mon, 31 Mar 2008 18:10:24 +0300

 --zYM0uCDKw75PZbzx
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: inline
 
 
 Hi,
 
 Although removing the limit from sh(1) is probably not a bad idea It
 doesn't help people using older releases or other operating systems.
 (At least NetBSD has the same 79 character limitation.)
 
 Here's a patch for shar(1) which limits the EOF marker length to maximum
 of 79 characters. If the marker would be longer then we use simply
 "END-of-file" as marker.
 
 I don't think that this code would be too complex to add.
 
 -- 
 Jaakko
 
 --zYM0uCDKw75PZbzx
 Content-Type: text/x-diff; charset=us-ascii
 Content-Disposition: attachment; filename="shar-limit-eofmarker.diff"
 
 PR: bin/118782
 
 Index: shar.sh
 ===================================================================
 RCS file: /home/ncvs/src/usr.bin/shar/shar.sh,v
 retrieving revision 1.3
 diff -u -r1.3 shar.sh
 --- shar.sh	29 Aug 1997 00:44:34 -0000	1.3
 +++ shar.sh	26 Mar 2008 17:51:26 -0000
 @@ -70,10 +70,14 @@
  		echo "echo c - $i"
  		echo "mkdir -p $i > /dev/null 2>&1"
  	else
 +		eofmarker="END-of-$i"
 +		if [ ${#eofmarker} -gt 79 ]; then
 +			eofmarker="END-of-file"
 +		fi
  		echo "echo x - $i"
 -		echo "sed 's/^X//' >$i << 'END-of-$i'"
 +		echo "sed 's/^X//' >$i << '$eofmarker'"
  		sed 's/^/X/' $i || exit
 -		echo "END-of-$i"
 +		echo "$eofmarker"
  	fi
  done
  echo exit
 
 --zYM0uCDKw75PZbzx--

From: Edwin Groothuis <edwin@mavetju.org>
To: FreeBSD Gnats Submit <freebsd-gnats-submit@freebsd.org>
Cc:  
Subject: Re: bin/118782: [patch] shar(1) sometimes creates broken archives
Date: Tue, 27 May 2008 14:51:38 +1000

 --OXfL5xGRrasGEqWY
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: inline
 
 This patch will make the output consistent by using md5 for everything
 (yes I just got bitten by the "create patch before checking gnats" bug)
 
 -- 
 Edwin Groothuis      |            Personal website: http://www.mavetju.org
 edwin@mavetju.org    |              Weblog: http://www.mavetju.org/weblog/
 
 --OXfL5xGRrasGEqWY
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: attachment; filename=a
 
 ? shar.1.gz
 Index: shar.sh
 ===================================================================
 RCS file: /home/ncvs/src/usr.bin/shar/shar.sh,v
 retrieving revision 1.3
 diff -u -r1.3 shar.sh
 --- shar.sh	29 Aug 1997 00:44:34 -0000	1.3
 +++ shar.sh	27 May 2008 04:50:44 -0000
 @@ -70,10 +70,12 @@
  		echo "echo c - $i"
  		echo "mkdir -p $i > /dev/null 2>&1"
  	else
 +		md5sum=`echo -n $i | md5`
 +		eofmarker="END-of-$md5sum"
  		echo "echo x - $i"
 -		echo "sed 's/^X//' >$i << 'END-of-$i'"
 +		echo "sed 's/^X//' >$i << '$md5sum'"
  		sed 's/^/X/' $i || exit
 -		echo "END-of-$i"
 +		echo "$md5sum"
  	fi
  done
  echo exit
 
 --OXfL5xGRrasGEqWY--
Responsible-Changed-From-To: freebsd-bugs->remko 
Responsible-Changed-By: remko 
Responsible-Changed-When: Tue May 27 07:49:51 UTC 2008 
Responsible-Changed-Why:  
I'll take it. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=118782 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/118782: commit references a PR
Date: Tue, 27 May 2008 09:45:23 +0000 (UTC)

 remko       2008-05-27 09:45:18 UTC
 
   FreeBSD src repository
 
   Modified files:
     usr.bin/shar         shar.sh 
   Log:
   Limit the EOF marker length to a maximum of 79
   characters. [1]
   
   Add $FreeBSD$ tag so that I can actually commit this.
   
   PR:             bin/118782
   Reported by:    Bjoern Koenig
   Patch by:       edwin, Jaakko Heinonen (not used patch)
   MFC after:      1 week
   Approved by:    imp (mentor, implicit)
   
   Revision  Changes    Path
   1.4       +5 -2      src/usr.bin/shar/shar.sh
 _______________________________________________
 cvs-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/cvs-all
 To unsubscribe, send any mail to "cvs-all-unsubscribe@freebsd.org"
 
State-Changed-From-To: open->patched 
State-Changed-By: gavin 
State-Changed-When: Wed Jun 11 13:04:28 UTC 2008 
State-Changed-Why:  
Mark as patched, this is fixed in HEAD 

http://www.freebsd.org/cgi/query-pr.cgi?pr=118782 
State-Changed-From-To: patched->closed 
State-Changed-By: remko 
State-Changed-When: Tue Jun 17 19:11:00 UTC 2008 
State-Changed-Why:  
merged to all relevant branches, cleaned up after discussion as well. 
Thanks for the submission! 

http://www.freebsd.org/cgi/query-pr.cgi?pr=118782 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/118782: commit references a PR
Date: Tue, 17 Jun 2008 19:11:04 +0000 (UTC)

 remko       2008-06-17 19:10:38 UTC
 
   FreeBSD src repository
 
   Modified files:        (Branch: RELENG_6)
     usr.bin/shar         shar.sh 
   Log:
   SVN rev 179850 on 2008-06-17 19:10:38Z by remko
   
   MFC rev 179355 and 179848 shar.sh
   
   r179355
   
     Limit the EOF marker length to a maximum of 79 characters. [1]
   
     Add $FreeBSD$ tag so that I can actually commit this.
   
     PR:             bin/118782
     Reported by:    Bjoern Koenig
     Patch by:       edwin, Jaakko Heinonen (not used patch)
     MFC after:      1 week
     Approved by:    imp (mentor, implicit)
   
   r179848:
     Remove superfluous eofmarker.
   
     Requested by:   Jaakko Heinonen
     Discussed with: Jaakko, edwin
   
   Revision  Changes    Path
   1.3.38.1  +4 -2      src/usr.bin/shar/shar.sh
 _______________________________________________
 cvs-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/cvs-all
 To unsubscribe, send any mail to "cvs-all-unsubscribe@freebsd.org"
 
>Unformatted:
