From owner-freebsd-current Fri Jul 28 0:47:16 2000 Delivered-To: freebsd-current@freebsd.org Received: from knight.cons.org (knight.cons.org [194.233.237.86]) by hub.freebsd.org (Postfix) with ESMTP id 7570437B551; Fri, 28 Jul 2000 00:47:10 -0700 (PDT) (envelope-from cracauer@knight.cons.org) Received: (from cracauer@localhost) by knight.cons.org (8.9.3/8.9.3) id JAA10827; Fri, 28 Jul 2000 09:47:08 +0200 (CEST) Date: Fri, 28 Jul 2000 09:47:08 +0200 From: Martin Cracauer To: Hajimu UMEMOTO Cc: kuriyama@FreeBSD.ORG, cracauer@FreeBSD.ORG, FreeBSD-current@FreeBSD.ORG Subject: Re: /bin/sh dumps core with here-document of 8bit text Message-ID: <20000728094707.A10655@cons.org> References: <7mr98fq7b4.wl@waterblue.imgsrc.co.jp> <20000728.150627.74708840.ume@mahoroba.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="qMm9M+Fa2AknHoGS" X-Mailer: Mutt 1.0.1i In-Reply-To: <20000728.150627.74708840.ume@mahoroba.org>; from ume@FreeBSD.ORG on Fri, Jul 28, 2000 at 03:06:27PM +0900 Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG --qMm9M+Fa2AknHoGS Content-Type: text/plain; charset=us-ascii In <20000728.150627.74708840.ume@mahoroba.org>, Hajimu UMEMOTO wrote: > >>>>> On Fri, 28 Jul 2000 12:09:51 +0900 > >>>>> Jun Kuriyama said: > > kuriyama> Shell script which contains here-document of 8bit text sometimes dumps > kuriyama> core. For example, please test this script in 4.1 or -current. > > I'm using this for workaround on IMASY's main server. 3.5-RELEASE or > later have this problem. > > --- bin/sh/parser.c.orig Mon Mar 20 19:51:04 2000 > +++ bin/sh/parser.c Fri Jun 30 17:15:38 2000 > @@ -909,9 +909,11 @@ > for (;;) { /* until end of line or end of word */ > CHECKSTRSPACE(3, out); /* permit 3 calls to USTPUTC */ > > +#if 0 > if (c < 0 && c != PEOF) > synentry = CWORD; > else > +#endif > synentry = syntax[c]; > > switch(synentry) { Hm, looks like I broke that in my 8-bit fixes. This code is native in that it passed control chars further down in the hope noone will execute them anymore, just taking them for real chars. Nice try. The problem is also not limited to here-documents: echo \202 # A real \202 will also dump core. Since literal strings cannot be made 8-bit clean without further cleanup, I think we should make this official, although in the following form, otherwise wrong characters are echoed. Anyone for whom this fix doesn't work? Martin -- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Martin Cracauer http://www.cons.org/cracauer/ BSD User Group Hamburg, Germany http://www.bsdhh.org/ --qMm9M+Fa2AknHoGS Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=sh-8bit ? test2 ? test1 ? l ? Makefile.cra ? builtins.c ? builtins.h ? mknodes ? nodes.h ? nodes.c ? mksyntax ? syntax.c ? syntax.h ? token.h ? y.tab.h ? y.tab.c ? arith.c ? arith_lex.c ? sh ? l4 ? mkinit ? init.c ? sh.1.gz ? .depend ? l3 ? l2 ? foo ? l5 Index: parser.c =================================================================== RCS file: /home/CVS-FreeBSD/src/bin/sh/parser.c,v retrieving revision 1.31 diff -c -r1.31 parser.c *** parser.c 2000/05/15 13:02:07 1.31 --- parser.c 2000/07/28 07:46:22 *************** *** 909,918 **** for (;;) { /* until end of line or end of word */ CHECKSTRSPACE(3, out); /* permit 3 calls to USTPUTC */ ! if (c < 0 && c != PEOF) synentry = CWORD; ! else ! synentry = syntax[c]; switch(synentry) { case CNL: /* '\n' */ --- 909,923 ---- for (;;) { /* until end of line or end of word */ CHECKSTRSPACE(3, out); /* permit 3 calls to USTPUTC */ ! if (c >= CTLESC && c <= CTLQUOTEMARK) { synentry = CWORD; ! fprintf(stderr, ! "Warning: internal control character in " ! "literal text, using '?' instead\n"); ! c = '?'; ! } ! ! synentry = syntax[c]; switch(synentry) { case CNL: /* '\n' */ --qMm9M+Fa2AknHoGS-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message