argconfig_parse() assigns pointers in cfg to point to memory allocated
in all_args. If this memory is freed, these pointers become dangling.
This is particularly dangerous if discovery.conf contains empty lines,
comment lines, or invalid lines.
Fix it by setting all transport parameter to NULL after processing each
line, and not proceeding if the basic parameters aren't set.
if (err)
goto free_and_continue;
+ if (!cfg.transport || !cfg.traddr)
+ goto free_and_continue;
+
err = flags = validate_output_format(cfg.output_format);
if (err < 0)
goto free_and_continue;
free_and_continue:
free(all_args);
free(argv);
+ cfg.transport = cfg.traddr = cfg.trsvcid =
+ cfg.host_traddr = NULL;
}
out: