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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <BY5PR11MB4024C5EB061A6B8BBFB485B4D9299@BY5PR11MB4024.namprd11.prod.outlook.com>
Date:   Fri, 21 May 2021 10:24:28 +0000
From:   "Denys Zagorui -X (dzagorui - GLOBALLOGIC INC at Cisco)" 
        <dzagorui@...co.com>
To:     Jiri Olsa <jolsa@...hat.com>
CC:     "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        "peterz@...radead.org" <peterz@...radead.org>,
        "mingo@...hat.com" <mingo@...hat.com>,
        "acme@...nel.org" <acme@...nel.org>,
        "mark.rutland@....com" <mark.rutland@....com>,
        "alexander.shishkin@...ux.intel.com" 
        <alexander.shishkin@...ux.intel.com>,
        "namhyung@...nel.org" <namhyung@...nel.org>
Subject: Re: [PATCH v5 1/3] perf report: compile tips.txt in perf binary

> that still does not solve that we set MAX_TIPS and have
> no way of checking that's still valid
> 
> how about something like below (completely untested):

Yes, looks good, i've tested it.
> 
> 
> static const char *perf_tip(void)
> {
>       char *start = _binary_Documentation_tips_txt_start;
>       char *tok, *tmp, *prev;
>       int pick, size;
>
>       size = _binary_Documentation_tips_txt_end - start;
>       pick = random() % size;
>
>       _binary_Documentation_tips_txt_start[size - 1] = 0;
>
>       for (tok = strtok_r(start, "\n", &tmp); tok;
>            tok = strtok_r(NULL, "\n", &tmp)) {
>               if (pick < (tok - start))
>                       return prev;
>               prev = tok;
>       }
>
>       return prev;
> }
> 
> this way you wouldn't need array with MAX_TIPS defined

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ