Re: [hackers] [sbase] [PATCH 1/3] find: Fix unterminated array in -ok primary
Quoth Evan Gates on Mon, Jun 15 2015 13:51 -0700: On Mon, Jun 15, 2015 at 12:27 PM, Wolfgang Corcoran-Mathe wrote: --- find.c | 1 + 1 file changed, 1 insertion(+) diff --git a/find.c b/find.c index dedf5a1..a870a90 100644 --- a/find.c +++ b/find.c @@ -429,6 +429,7 @@ pri_ok(struct arg *arg) /* insert filename everywhere user gave us {} */ for (brace = o->braces; *brace; brace++) **brace = arg->path; + *brace = NULL; switch((pid = fork())) { case -1: -- 2.3.5 Not needed there, *brace will already be NULL or the loop wouldn't have stopped (the cause of the segfault). Needed in get_ok_arg() so that it is NULL when we get here. See attached. It occurred to me shortly after sending that patch that this should have been in get_ok_arg(), as with get_exec_arg(). But without this patch (or yours), I get a segfault when the end of the arg list is reached. Your patch is obviously the right one, but I would like to understand why both seem to have the same effect. There is another semi-bug in -ok's input parsing. If the char read into reply in pri_ok() at line 415 is a newline the user will have to enter another newline to skip the file. This seems clumsy, but it might be what you want. Regards, -- WCM
Re: [hackers] [sbase] [PATCH 1/3] find: Fix unterminated array in -ok primary
On Mon, Jun 15, 2015 at 12:27 PM, Wolfgang Corcoran-Mathe wrote: > --- > find.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/find.c b/find.c > index dedf5a1..a870a90 100644 > --- a/find.c > +++ b/find.c > @@ -429,6 +429,7 @@ pri_ok(struct arg *arg) > /* insert filename everywhere user gave us {} */ > for (brace = o->braces; *brace; brace++) > **brace = arg->path; > + *brace = NULL; > > switch((pid = fork())) { > case -1: > -- > 2.3.5 > > Not needed there, *brace will already be NULL or the loop wouldn't have stopped (the cause of the segfault). Needed in get_ok_arg() so that it is NULL when we get here. See attached. -emg From d842da4c8f9fffd304858a0ae62f1c2933c97cef Mon Sep 17 00:00:00 2001 From: Evan Gates Date: Mon, 15 Jun 2015 13:49:38 -0700 Subject: [PATCH] NULL terminate braces array in get_ok_arg --- find.c | 1 + 1 file changed, 1 insertion(+) diff --git a/find.c b/find.c index dcefca5..e9d8c1d 100644 --- a/find.c +++ b/find.c @@ -635,6 +635,7 @@ get_ok_arg(char *argv[], union extra *extra) for (arg = argv, braces = o->braces; *arg; arg++) if (!strcmp(*arg, "{}")) *braces++ = arg; + *braces = NULL; gflags.print = 0; return arg; -- 2.4.3
[hackers] [sbase] [PATCH 1/3] find: Fix unterminated array in -ok primary
--- find.c | 1 + 1 file changed, 1 insertion(+) diff --git a/find.c b/find.c index dedf5a1..a870a90 100644 --- a/find.c +++ b/find.c @@ -429,6 +429,7 @@ pri_ok(struct arg *arg) /* insert filename everywhere user gave us {} */ for (brace = o->braces; *brace; brace++) **brace = arg->path; + *brace = NULL; switch((pid = fork())) { case -1: -- 2.3.5