]> git.ozlabs.org Git - petitboot/commitdiff
Fix pb-discover segfaults caused by list corruption.
authorBrandon Bergren <git@bdragon.rtk0.net>
Sun, 10 Jun 2018 18:21:58 +0000 (13:21 -0500)
committerSamuel Mendoza-Jonas <sam@mendozajonas.com>
Tue, 12 Jun 2018 00:56:35 +0000 (10:56 +1000)
I was seeing list corruption and segfaults in pb-discover on my Talos
II when using both yaboot and kboot config files on the same device.

My assumption is that discover_context_add_boot_option() was being
called on the same pointer more than once.

So, null the pointer right after the call. The ownership was transferred
anyway so the parsers should not keep it around.

Signed-off-by: Brandon Bergren <git@bdragon.rtk0.net>
Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
discover/pxe-parser.c
discover/syslinux-parser.c
discover/yaboot-parser.c

index fd8b8e866d012ac4baeb8d6a772bd90eadbb9a03..470dd83f08ad71590339156ac1bc10c853152532 100644 (file)
@@ -41,6 +41,7 @@ static void pxe_finish(struct conf_context *conf)
                if (info->proxy)
                        info->opt->proxy = talloc_strdup(info->opt, info->proxy);
                discover_context_add_boot_option(conf->dc, info->opt);
+               info->opt = NULL;
        }
 }
 
index be7b94aa5d5b2ccb625ebea1fc23212fda8784c2..c611ac92b794e878a87d4793d9557df2243abe9e 100644 (file)
@@ -408,6 +408,7 @@ static void syslinux_finalize(struct conf_context *conf)
                conf_strip_str(opt->description);
 
                discover_context_add_boot_option(dc, d_opt);
+               d_opt = NULL;
                continue;
 
 fail:
index 42db95bcfbbb1ae758b4704303baa3b3992dc5d8..b06248f535f35eb0c05b3e2bf2437a1516cafbdf 100644 (file)
@@ -172,6 +172,7 @@ static void yaboot_finish(struct conf_context *conf)
                state->opt->option->is_default = true;
 
        discover_context_add_boot_option(conf->dc, state->opt);
+       state->opt = NULL;
 }
 
 static void yaboot_process_pair(struct conf_context *conf, const char *name,