[CRIU] [PATCH 2/2] config: Don't free memory in PARSING_USER_CONF

Radostin Stoyanov rstoyanov1 at gmail.com
Sun Jan 20 13:22:19 MSK 2019


On 19/01/2019 21:00, Radostin Stoyanov wrote:
> On 19/01/2019 18:11, Radostin Stoyanov wrote:
>> On 19/01/2019 17:23, Radostin Stoyanov wrote:
>>> On restore, when state=PARSING_USER_CONF the _argv pointer
>>> points to the location which contains the envirnment variables
>>> and should not be free()-ed.
>>>
>>> Signed-off-by: Radostin Stoyanov <rstoyanov1 at gmail.com>
>>> ---
>>>  criu/config.c | 2 +-
>>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>> diff --git a/criu/config.c b/criu/config.c
>>> index 89afdd748..f3c8d4254 100644
>>> --- a/criu/config.c
>>> +++ b/criu/config.c
>>> @@ -509,7 +509,7 @@ int parse_options(int argc, char **argv, bool *usage_error,
>>>  		/* Only if opt is -1 we are going to the next configuration input */
>>>  		if (opt == -1) {
>>>  			/* Do not free any memory if it points to argv */
>>> -			if (state != PARSING_ARGV + 1) {
>>> +			if (state != PARSING_ARGV + 1 && state != PARSING_USER_CONF) {
>>>  				int i;
>>>  				for (i=1; i < _argc; i++) {
>>>  					free(_argv[i]);
>> I sent this patch because I am getting the error:
>>
>> (00.000000) Unable to get $HOME directory, local configuration file will
>> not be used.
>> (00.000014) Warn  (criu/log.c:203): The early log isn't empty
>> (00.000022) Version: 3.11 (gitid
>> v3.11-125-g93043916c)                        
>>
>> On Arch Linux with kernel version 5.0.0-rc2-g6b529fb0a3ea
>> However, I just noticed that the error does not reproduce on Fedora 29.
>> I will continue to investigate.
>>
>
The issue seems to that we don't initialize the allocated memory that is
used to store the content of the configuration file.

--- a/criu/config.c
+++ b/criu/config.c
@@ -59,6 +59,7 @@ static char ** parse_config(char *filepath)
                fclose(configfile);
                exit(1);
        }
+       memset(configuration, 0, config_size * sizeof(char *));
        /*
         * Initialize first element, getopt ignores it.
         */

I will send a revised version of the patch.

Radostin


More information about the CRIU mailing list