Recovering tilde expansion from config files. Thanks to Juha Erkkilä for reporting and investigating. wordexp() code copied and adapted from old Bill's code.

This commit is contained in:
Pere Pujal i Carabantes 2015-09-13 23:42:40 +00:00
parent b0f9edcc8e
commit c692eca118

View file

@ -21623,11 +21623,24 @@ static void parse_file_options(struct cfginfo *restrict tmpcfg, const char *file
arg = strchr(str,'='); arg = strchr(str,'=');
if(arg) if(arg)
*arg++ = '\0'; *arg++ = '\0';
#ifdef __linux__
/* Perform shell expansion */
wordexp_t result;
wordexp(arg, &result, 0);
arg = strdup(result.we_wordv[0]);
wordfree(&result);
#endif
// FIXME: leaking mem here, but the trouble is that these // FIXME: leaking mem here, but the trouble is that these
// strings get mixed in with ones from .data and .rodata // strings get mixed in with ones from .data and .rodata
// and free() isn't smart about the situation -- also some // and free() isn't smart about the situation -- also some
// of the strings end up being kept around // of the strings end up being kept around
parse_one_option(tmpcfg,str,strdup(arg),filename); parse_one_option(tmpcfg,str,strdup(arg),filename);
#ifdef __linux__
free(arg);
#endif
} }
fclose(fi); fclose(fi);