Fix for #7819: Properly trim \n on rarun2 envfile

Newline characters are not properly removed when reading env vars from envfile
of a rarun2 profile. Although tempted to to use `r_str_trim_tail`, manual
trimming is used instead in order to disrupt env vars as little as possible
for funky cases such as when including shellcodes, etc...
This commit is contained in:
NighterMan 2017-06-26 08:35:43 +02:00
parent c1cb93aaf8
commit 42836cb353

View File

@ -449,6 +449,7 @@ R_API bool r_run_parseline (RRunProfile *p, char *b) {
}
} else if (!strcmp (b, "envfile")) {
char *p, buf[1024];
size_t len;
FILE *fd = fopen (e, "r");
if (!fd) {
eprintf ("Cannot open '%s'\n", e);
@ -464,8 +465,11 @@ R_API bool r_run_parseline (RRunProfile *p, char *b) {
}
p = strchr (buf, '=');
if (p) {
*p = 0;
r_sys_setenv (buf, p + 1);
*p++ = 0;
len = strlen(p);
if (p[len-1] == '\n') p[len-1] = 0;
if (p[len-2] == '\r') p[len-2] = 0;
r_sys_setenv (buf, p);
}
}
fclose (fd);