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, 22 Dec 2010 13:57:39 +0900
From:	Masami Hiramatsu <masami.hiramatsu.pt@...achi.com>
To:	Arnaldo Carvalho de Melo <acme@...radead.org>
Cc:	Ingo Molnar <mingo@...e.hu>, Steven Rostedt <rostedt@...dmis.org>,
	Srikar Dronamraju <srikar@...ux.vnet.ibm.com>,
	linux-kernel@...r.kernel.org, 2nddept-manager@....hitachi.co.jp,
	Peter Zijlstra <a.p.zijlstra@...llo.nl>,
	Paul Mackerras <paulus@...ba.org>
Subject: Re: [PATCH -tip 2/4] [BUGFIX]perf: Fix strlist__parse_list to	handle
 const string

(2010/12/22 3:23), Arnaldo Carvalho de Melo wrote:
> Em Fri, Dec 17, 2010 at 10:12:06PM +0900, Masami Hiramatsu escreveu:
>> Fix strlist__parse_list to handle const string. Without this patch,
>> strlist__parse_list() causes SEGV when caller passes a constant
>> string.
>  
>> +++ b/tools/perf/util/strlist.c
>> @@ -136,13 +136,19 @@ static int strlist__parse_list_entry(struct strlist *self, const char *s)
>>  
>>  int strlist__parse_list(struct strlist *self, const char *s)
>>  {
>> -	char *sep;
>> +	char *sep, *tmp;
>>  	int err;
>>  
>> +	/* This method requires strdup, because this changes given string */
>> +	if (!self->dupstr)
>> +		return -EINVAL;
>> +
> 
> Why is the above check needed if you solved the problem by strnduping at
> each separator?

Without dupstr, strlist(str_node__delete) will not release
allocated buffer... And we have to release it if the parsed
string started with "file://" after loading file.

(Ah, and there is a same problem in strlist__load() too...)

> Wouldn't be better to just stop changing the string by passing the
> length to strlist__parse_list_entry, etc?

Yeah, it could be, but in that case, we need changing code
wider.
I think this is the simplest solution. :)

(Of course, we have to check dupstr flag on top of strlist__load too.)

Thank you,

>>  	while ((sep = strchr(s, ',')) != NULL) {
>> -		*sep = '\0';
>> -		err = strlist__parse_list_entry(self, s);
>> -		*sep = ',';
>> +		tmp = strndup(s, sep - s);
>> +		if (tmp == NULL)
>> +			return -ENOMEM;
>> +		err = strlist__parse_list_entry(self, tmp);
>> +		free(tmp);
>>  		if (err != 0)
>>  			return err;
>>  		s = sep + 1;

-- 
Masami HIRAMATSU
2nd Dept. Linux Technology Center
Hitachi, Ltd., Systems Development Laboratory
E-mail: masami.hiramatsu.pt@...achi.com
--
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