mirror of
https://github.com/radareorg/radare2.git
synced 2025-01-26 15:54:59 +00:00
Escape environment vars in the default rarun profile (#17441) ##debug
This commit is contained in:
parent
e7b86490e1
commit
ea1151d143
@ -256,6 +256,7 @@ R_API int r_run_config_env(RRunProfile *p);
|
||||
R_API int r_run_start(RRunProfile *p);
|
||||
R_API void r_run_reset(RRunProfile *p);
|
||||
R_API bool r_run_parsefile(RRunProfile *p, const char *b);
|
||||
R_API char *r_run_get_environ_profile(char **environ);
|
||||
|
||||
/* rapipe */
|
||||
R_API R2Pipe *rap_open(const char *cmd);
|
||||
|
@ -386,16 +386,8 @@ R_API int r_main_radare2(int argc, const char **argv) {
|
||||
|
||||
r_sys_env_init ();
|
||||
// Create rarun2 profile with startup environ
|
||||
char *envprofile = NULL;
|
||||
char **e = r_sys_get_environ ();
|
||||
if (e) {
|
||||
RStrBuf *sb = r_strbuf_new (NULL);
|
||||
while (e && *e) {
|
||||
r_strbuf_appendf (sb, "setenv=%s\n", *e);
|
||||
e++;
|
||||
}
|
||||
envprofile = r_strbuf_drain (sb);
|
||||
}
|
||||
char **env = r_sys_get_environ ();
|
||||
char *envprofile = r_run_get_environ_profile (env);
|
||||
|
||||
if (r_sys_getenv_asbool ("R2_DEBUG")) {
|
||||
char *sysdbg = r_sys_getenv ("R2_DEBUG_TOOL");
|
||||
|
@ -1228,3 +1228,25 @@ R_API int r_run_start(RRunProfile *p) {
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
R_API char *r_run_get_environ_profile(char **env) {
|
||||
if (!env) {
|
||||
return NULL;
|
||||
}
|
||||
RStrBuf *sb = r_strbuf_new (NULL);
|
||||
while (*env) {
|
||||
char *k = strdup (*env);
|
||||
char *v = strchr (k, '=');
|
||||
if (v) {
|
||||
*v++ = 0;
|
||||
v = r_str_escape_latin1 (v, false, true, true);
|
||||
if (v) {
|
||||
r_strbuf_appendf (sb, "setenv=%s=\"%s\"\n", k, v);
|
||||
free (v);
|
||||
}
|
||||
}
|
||||
free (k);
|
||||
env++;
|
||||
}
|
||||
return r_strbuf_drain (sb);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user