Date: Fri, 28 Jul 2000 09:03:49 +0200 From: Martin Cracauer <cracauer@cons.org> To: Jun Kuriyama <kuriyama@FreeBSD.ORG> Cc: cracauer@FreeBSD.ORG, Current <FreeBSD-current@FreeBSD.ORG> Subject: Re: /bin/sh dumps core with here-document of 8bit text Message-ID: <20000728090349.A9976@cons.org> In-Reply-To: <7mr98fq7b4.wl@waterblue.imgsrc.co.jp>; from kuriyama@FreeBSD.ORG on Fri, Jul 28, 2000 at 12:09:51PM %2B0900 References: <7mr98fq7b4.wl@waterblue.imgsrc.co.jp>
next in thread | previous in thread | raw e-mail | index | archive | help
In <7mr98fq7b4.wl@waterblue.imgsrc.co.jp>, Jun Kuriyama wrote: > #!/bin/sh > cat <<EOF > [8bit text which contains 0x82 character] > EOF I'm very short of time these days, but here are thoughts and a backtrace: 0x82 == \202 == CTLVAR in the parser. For real variable expansion, the parser inserts \202 into the input string. Furthermore, it is an error that the forking shell doesn't detect that its forked counterpart dumped core. I see two solutions: 1) It seems that you can work around the coredump by looking at the next char after \202. For real expansions of variables in here-documents that is \201. Once can probably determine all possible legal combinations and ignore others. However, that would just prevent this coredump and would not support processing the CTL* chars as literal chars in here-documents, at the very least they will be eaten. 2) move the CTL* stuff from expand.h to values outside the char domain. Do do this, all input strings must be converted from char* to int* in the first steps of the parser, all buffers must hold int*, which means that they cannot be displayed to the terminal or presented as input to external programs without converting them back. Of course, I will do the latter :-) However, I'm in the middle of preparation for a job interview, so that is not possible right now. Anyone trying to fix this, especially going the first path, keep in mind that you must not break variable expansion in here-documents: foo=42 cat <<EOF echo $foo EOF (gdb) bt #0 evalvar (p=0x80b998c "\na;sldk\n", flag=0) at expand.c:783 #1 0x804ce8e in argstr (p=0x80b9980 "jhsdd903kd\n\202\na;sldk\n", flag=0) at expand.c:245 #2 0x804cc26 in expandarg (arg=0x80b9998, arglist=0x0, flag=0) at expand.c:169 #3 0x804cbbb in expandhere (arg=0x80b9998, fd=3) at expand.c:144 #4 0x8056d22 in openhere (redir=0x80b994c) at redir.c:269 #5 0x8056bd5 in openredirect (redir=0x80b994c, memory=0xbfbff1f8 "") at redir.c:226 #6 0x8056a59 in redirect (redir=0x80b994c, flags=0) at redir.c:157 #7 0x804b9ae in evalcommand (cmd=0x80b9970, flags=1, backcmd=0x0) at eval.c:888 #8 0x804a920 in evaltree (n=0x80b9970, flags=0) at eval.c:269 #9 0x8051a47 in cmdloop (top=1) at main.c:253 #10 0x80519b5 in main (argc=2, argv=0xbfbff3f8) at main.c:202 #11 0x8048135 in _start () -- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Martin Cracauer <cracauer@cons.org> http://www.cons.org/cracauer/ BSD User Group Hamburg, Germany http://www.bsdhh.org/ To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20000728090349.A9976>