lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZZcdDyyADG8dP8LM@kernel.org>
Date: Thu, 4 Jan 2024 18:03:11 -0300
From: Arnaldo Carvalho de Melo <acme@...nel.org>
To: Ian Rogers <irogers@...gle.com>
Cc: Peter Zijlstra <peterz@...radead.org>, Ingo Molnar <mingo@...hat.com>,
	Mark Rutland <mark.rutland@....com>,
	Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
	Jiri Olsa <jolsa@...nel.org>, Namhyung Kim <namhyung@...nel.org>,
	Adrian Hunter <adrian.hunter@...el.com>,
	Chenyuan Mi <cymi20@...an.edu.cn>, linux-kernel@...r.kernel.org,
	linux-perf-users@...r.kernel.org
Subject: Re: [PATCH v1 1/3] lib subcmd: Fix memory leak in uniq

Em Tue, Jan 02, 2024 at 11:30:39AM -0800, Ian Rogers escreveu:
> On Thu, Dec 7, 2023 at 4:05 PM Ian Rogers <irogers@...gle.com> wrote:
> >
> > uniq will write one command name over another causing the overwritten
> > string to be leaked. Fix by doing a pass that removes duplicates and a
> > second that removes the holes.
> >
> > Signed-off-by: Ian Rogers <irogers@...gle.com>
> 
> Ping for this series, no comments since sent.

I applied the first one, the fix for uniq(), but somehow the second
didn't work for me as in your examples, nor the third, the output is the
same as before.

- Arnaldo
 
> Thanks,
> Ian
> 
> > ---
> >  tools/lib/subcmd/help.c | 18 ++++++++++++++----
> >  1 file changed, 14 insertions(+), 4 deletions(-)
> >
> > diff --git a/tools/lib/subcmd/help.c b/tools/lib/subcmd/help.c
> > index adfbae27dc36..8561b0f01a24 100644
> > --- a/tools/lib/subcmd/help.c
> > +++ b/tools/lib/subcmd/help.c
> > @@ -52,11 +52,21 @@ void uniq(struct cmdnames *cmds)
> >         if (!cmds->cnt)
> >                 return;
> >
> > -       for (i = j = 1; i < cmds->cnt; i++)
> > -               if (strcmp(cmds->names[i]->name, cmds->names[i-1]->name))
> > -                       cmds->names[j++] = cmds->names[i];
> > -
> > +       for (i = 1; i < cmds->cnt; i++) {
> > +               if (!strcmp(cmds->names[i]->name, cmds->names[i-1]->name))
> > +                       zfree(&cmds->names[i - 1]);
> > +       }
> > +       for (i = 0, j = 0; i < cmds->cnt; i++) {
> > +               if (cmds->names[i]) {
> > +                       if (i == j)
> > +                               j++;
> > +                       else
> > +                               cmds->names[j++] = cmds->names[i];
> > +               }
> > +       }
> >         cmds->cnt = j;
> > +       while (j < i)
> > +               cmds->names[j++] = NULL;
> >  }
> >
> >  void exclude_cmds(struct cmdnames *cmds, struct cmdnames *excludes)
> > --
> > 2.43.0.472.g3155946c3a-goog
> >
> 

-- 

- Arnaldo

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ