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]
Date:	Wed, 3 Jun 2015 12:30:45 +0200
From:	Jiri Olsa <jolsa@...hat.com>
To:	Sukadev Bhattiprolu <sukadev@...ux.vnet.ibm.com>
Cc:	mingo@...hat.com, ak@...ux.intel.com,
	Michael Ellerman <mpe@...erman.id.au>,
	Arnaldo Carvalho de Melo <acme@...nel.org>,
	namhyung@...nel.org, linuxppc-dev@...ts.ozlabs.org,
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH v13 02/14] perf, tools, jevents: Program to convert JSON
 file to C style file

On Tue, Jun 02, 2015 at 10:12:02AM -0700, Sukadev Bhattiprolu wrote:

SNIP

> +
> +static char *file_name_to_table_name(char *fname)
> +{
> +	unsigned int i, j;
> +	int c;
> +	int n = 1024;		/* use max variable length? */

I think this should be at least PATH_MAX, or you might
actually use asprintf and have all below done within
one line or so

jirka

> +	char *tblname;
> +	char *p;
> +
> +	tblname = malloc(n);
> +	if (!tblname)
> +		return NULL;
> +
> +	p = basename(fname);
> +
> +	memset(tblname, 0, n);
> +
> +	/* Ensure table name starts with an alphabetic char */
> +	strcpy(tblname, "pme_");
> +
> +	n = strlen(fname) + strlen(tblname);
> +	n = min(1024, n);
> +
> +	for (i = 0, j = strlen(tblname); i < strlen(fname); i++, j++) {
> +		c = p[i];
> +		if (isalnum(c) || c == '_')
> +			tblname[j] = c;
> +		else if (c == '-')
> +			tblname[j] = '_';
> +		else if (c == '.') {
> +			tblname[j] = '\0';
> +			break;
> +		} else {
> +			pr_err("%s: Invalid character '%c' in file name %s\n",
> +					prog, c, p);
> +			free(tblname);
> +			return NULL;
> +		}
> +	}
> +
> +	return tblname;
> +}

SNIP
--
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