X-Git-Url: https://git.ozlabs.org/?a=blobdiff_plain;f=discover%2Fgrub2%2Fscript.c;h=2aaf1d3d2cb1495a63c48fe7d31f72882d921b52;hb=a2d0866fc8a366700d256f0f8ae8075956057fe4;hp=d0b824aebcb9965e63d2ec0d0cb631da0a2dfc5d;hpb=ffc167572a9d56c52908aebefe62ba3e3e2a9cf8;p=petitboot diff --git a/discover/grub2/script.c b/discover/grub2/script.c index d0b824a..2aaf1d3 100644 --- a/discover/grub2/script.c +++ b/discover/grub2/script.c @@ -23,8 +23,8 @@ container_of(stmt, struct grub2_statement_conditional, st) struct env_entry { - const char *name; - const char *value; + char *name; + char *value; struct list_item list; }; @@ -35,6 +35,8 @@ struct grub2_symtab_entry { struct list_item list; }; +static const char *default_prefix = "/boot/grub"; + static struct grub2_symtab_entry *script_lookup_function( struct grub2_script *script, const char *name) { @@ -73,11 +75,13 @@ void script_env_set(struct grub2_script *script, if (!entry) { entry = talloc(script, struct env_entry); - entry->name = name; + entry->name = talloc_strdup(entry, name); list_add(&script->environment, &entry->list); + } else { + talloc_free(entry->value); } - entry->value = value; + entry->value = talloc_strdup(entry, value); } static bool expand_var(struct grub2_script *script, struct grub2_word *word) @@ -401,7 +405,7 @@ static void init_env(struct grub2_script *script) env = talloc(script, struct env_entry); env->name = talloc_strdup(env, "prefix"); - env->value = talloc_strdup(env, "/"); + env->value = talloc_strdup(env, default_prefix); list_add(&script->environment, &env->list); }