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] [day] [month] [year] [list]
Date:   Tue, 1 Jan 2019 19:00:51 +0100
From:   Jiri Olsa <jolsa@...hat.com>
To:     Arnaldo Carvalho de Melo <acme@...nel.org>
Cc:     Steven Rostedt <rostedt@...dmis.org>,
        LKML <linux-kernel@...r.kernel.org>,
        Ingo Molnar <mingo@...nel.org>,
        Namhyung Kim <namhyung@...nel.org>,
        Alexander Shishkin <alexander.shishkin@...ux.intel.com>
Subject: Re: perf: Use strcmp(str, "const") instead of strncmp(str, "const",
 sizeof("const"))

On Thu, Dec 20, 2018 at 03:55:53PM -0300, Arnaldo Carvalho de Melo wrote:
> Em Thu, Dec 20, 2018 at 12:26:01PM -0500, Steven Rostedt escreveu:
> > As strncmp(str, "const", sizeof("const") is exactly the same as
> > strcmp(str, "const") use that instead, otherwise it is confusing.
> > 
> > sizeof("const") includes the nul terminator ('\0') of the string
> > "const", and that means strncmp() will only return a match if str and
> > "const" are exactly the same, which is what strcmp() does.
> 
> There are more of those, that are there from time immemorial, lemme see
> if the original intention can be found... 
> 
> commit 26d330226b9cf6208daae9b0b3697980c8fb51d8
> Author: Jiri Olsa <jolsa@...hat.com>
> Date:   Tue Aug 7 15:20:47 2012 +0200
> 
>     perf tools: Support for DWARF mode callchain
> 
> ----------------
> 
> I thought this could be because at the time strchr was used and thus the
> name would be in a buffer followed by ',' or other separator, but
> strtok_r() was used, so your patch should simplify things.

yea, strtok_r returns null-terminated string containing the next token,
so there's always trailing null terminator.. so those strncmp calls
work properly

jirka

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ