[CRIU] [PATCH 4/7] cgroup: use construct_string() in rewrite_cgsets()

Stanislav Kinsburskiy skinsbursky at odin.com
Wed Dec 16 12:53:08 PST 2015



16.12.2015 18:46, Pavel Emelyanov пишет:
> On 12/16/2015 06:33 PM, Stanislav Kinsburskiy wrote:
>> Signed-off-by: Stanislav Kinsburskiy <skinsbursky at virtuozzo.com>
>> ---
>>   cgroup.c |   12 +++---------
>>   1 file changed, 3 insertions(+), 9 deletions(-)
>>
>> diff --git a/cgroup.c b/cgroup.c
>> index 4d603b7..343cd23 100644
>> --- a/cgroup.c
>> +++ b/cgroup.c
>> @@ -1315,16 +1315,10 @@ static int rewrite_cgsets(CgroupEntry *cge, char **controllers, int n_controller
>>   
>>   				/* +1 to get rid of leading /, again */
>>   				int off = strlen(from) + 1;
>> -
>> -				/* +1 for trailing NULL */
>> -				int newlen = strlen(to) + strlen(cg->path + off) + 1;
>> -				char *m = xmalloc(newlen * sizeof(char*));
>> -				if (!m)
>> +				cg->path = construct_string("%s%s", to,
>> +							    cg->path + off);
>> +				if (!cg->path)
>>   					return -1;
>> -
>> -				sprintf(m, "%s%s", to, cg->path + off);
>> -				free(cg->path);
> Original cg->path starts to leak with this patch.

Yes. Will fix it.

>> -				cg->path = m;
>>   			}
>>   		}
>>   
>>
>> _______________________________________________
>> CRIU mailing list
>> CRIU at openvz.org
>> https://lists.openvz.org/mailman/listinfo/criu
>> .
>>



More information about the CRIU mailing list