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: <CAOJsxLGctG0ysbN+-F1Ce=LCtUT4eTs4eebX1kycq6A2zTnqYw@mail.gmail.com>
Date:	Tue, 31 Mar 2015 10:00:15 +0300
From:	Pekka Enberg <penberg@...nel.org>
To:	Stephane Eranian <eranian@...gle.com>
Cc:	LKML <linux-kernel@...r.kernel.org>,
	Arnaldo Carvalho de Melo <acme@...hat.com>,
	Peter Zijlstra <peterz@...radead.org>,
	Ingo Molnar <mingo@...e.hu>, Andi Kleen <ak@...ux.intel.com>,
	Jiri Olsa <jolsa@...hat.com>,
	Namhyung Kim <namhyung@...nel.org>, cel@...ibm.com,
	sukadev@...ux.vnet.ibm.com, sonnyrao@...omium.org,
	johnmccutchan@...gle.com, David Ahern <dsahern@...il.com>,
	adrian.hunter@...el.com, Pawel Moll <pawel.moll@....com>
Subject: Re: [PATCH v6 2/4] perf tools: add Java demangling support

Hi Stephane,

On Tue, Mar 31, 2015 at 1:19 AM, Stephane Eranian <eranian@...gle.com> wrote:
> +#define BASE_ENT(c, n) [c-'A']=n
> +static const char *base_types['Z'-'A' + 1]={
> +       BASE_ENT('B', "byte" ),
> +       BASE_ENT('C', "char" ),
> +       BASE_ENT('D', "double" ),
> +       BASE_ENT('F', "float" ),
> +       BASE_ENT('I', "int" ),
> +       BASE_ENT('J', "long" ),
> +       BASE_ENT('S', "short" ),
> +       BASE_ENT('Z', "bool" ),

It's "boolean", not "bool" in JVM speak.

> +static char *
> +__demangle_java_sym(const char *str, const char *end, char *buf, int maxlen, int mode)
> +{
> +       int rlen = 0;
> +       int array = 0;
> +       int narg = 0;
> +       const char *q;
> +
> +       if (!end)
> +               end = str + strlen(str);
> +
> +       for (q = str; q != end; q++) {
> +
> +               if (rlen == (maxlen - 1))
> +                       break;
> +
> +               switch (*q) {
> +               case 'L':
> +                       if (mode == MODE_PREFIX || mode == MODE_CTYPE) {
> +                               if (mode == MODE_CTYPE) {
> +                                       if (narg)
> +                                               rlen += scnprintf(buf + rlen, maxlen - rlen, ", ");
> +                                       narg++;
> +                               }
> +                               rlen += scnprintf(buf + rlen, maxlen - rlen, "class ");
> +                               if (mode == MODE_PREFIX)
> +                                       mode = MODE_CLASS;
> +                       } else
> +                               buf[rlen++] = *q;
> +                       break;

This looks odd to me. "L" marks the beginning of an class name and
it's terminated by ";". You could just strhchr() the terminator and
simply copy the name to "buf" and drop cases ';', '/', and the default
label fro the switch statement.

> +char *
> +java_demangle_sym(const char *str, int flags)
> +{

[snip]

> +       /*
> +        * expansion factor estimated to 3x
> +        */
> +       len = strlen(str) * 3 + 1;
> +       buf = malloc(len);
> +       if (!buf)
> +               return NULL;

Truncated symbols are lame. Can't you use realloc() to ensure that
never happens?

- Pekka
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ