Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: printf %q segfault
- X-seq: zsh-workers 39678
- From: Peter Stephenson <p.stephenson@xxxxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: Re: printf %q segfault
- Date: Wed, 19 Oct 2016 09:52:27 +0100
- Cms-type: 201P
- In-reply-to: <20161018205715.09036030@ntlworld.com>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- Organization: Samsung Cambridge Solution Centre
- References: <CAMtVo_N+O_-s-H4-ih=N=oQ5bTRVbgJ9Odk6JCMiv3E-Lzsnmw@mail.gmail.com> <20161016160312.GA695@fujitsu.shahaf.local2> <CGME20161018200323eucas1p1270cf7c97828ba75c5bde02126a103c7@eucas1p1.samsung.com> <20161018205715.09036030@ntlworld.com>
On Tue, 18 Oct 2016 20:57:15 +0100
Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx> wrote:
> On Sun, 16 Oct 2016 16:03:12 +0000
> Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx> wrote:
>
> > lolilolicon wrote on Sun, Oct 16, 2016 at 22:58:14 +0800:
> > > The following produces segmentation fault:
> > >
> > > printf '%q' 你
> >
> > The reason 0xA0 is output literally is that the code takes the "if (itok(*u))"
> > branch in quotestring(); if it didn't take that branch, it'd behave
> > correctly.
>
> mumble
I don't think we need the utils.c hunk. We shouldn't meet an unmetafied
token when the input is handled properly, unless the input actually is
still tokenised. There's at least one place where this does happen, I
think down in completion.
pws
diff --git a/Src/builtin.c b/Src/builtin.c
index 8b8b217..2db739f 100644
--- a/Src/builtin.c
+++ b/Src/builtin.c
@@ -4874,9 +4874,10 @@ bin_print(char *name, char **args, Options ops, int func)
break;
case 'q':
stringval = curarg ?
- quotestring(curarg, QT_BACKSLASH_SHOWNULL) : &nullstr;
+ quotestring(metafy(curarg, curlen, META_USEHEAP),
+ QT_BACKSLASH_SHOWNULL) : &nullstr;
*d = 's';
- print_val(stringval);
+ print_val(unmetafy(stringval, &curlen));
break;
case 'd':
case 'i':
diff --git a/Test/D07multibyte.ztst b/Test/D07multibyte.ztst
index 1b1d042..3a6e955 100644
--- a/Test/D07multibyte.ztst
+++ b/Test/D07multibyte.ztst
@@ -579,3 +579,7 @@
0:Sorting of metafied Polish characters
>a ą b c ć d e ę f
>a ą b c ć d e ę f
+
+ printf '%q%q\n' 你你
+0:printf %q and quotestring and general metafy / token madness
+>你你
Messages sorted by:
Reverse Date,
Date,
Thread,
Author