mirror of
https://github.com/radareorg/radare2.git
synced 2024-11-26 22:50:48 +00:00
Fix truncated issue with long dir.prefix is used
- Small optimization when concatenating the home
This commit is contained in:
parent
1936f2d047
commit
a488760903
@ -2035,8 +2035,8 @@ R_API const char *r_core_anal_optype_colorfor(RCore *core, ut64 addr, bool verbo
|
||||
|
||||
static void r_core_setenv (RCore *core) {
|
||||
char *e = r_sys_getenv ("PATH");
|
||||
char *h = r_str_home (R2_HOME_BIN R_SYS_ENVSEP);
|
||||
char *n = r_str_newf ("%s%s", h, e);
|
||||
char *h = r_str_home (R2_HOME_BIN);
|
||||
char *n = r_str_newf ("%s%s%s", h, R_SYS_ENVSEP, e);
|
||||
r_sys_setenv ("PATH", n);
|
||||
free (n);
|
||||
free (h);
|
||||
|
@ -304,10 +304,11 @@ R_API char *r_str_home(const char *str) {
|
||||
if (!dst) {
|
||||
goto fail;
|
||||
}
|
||||
strcpy (dst, home);
|
||||
int home_len = strlen (home);
|
||||
memcpy (dst, home, home_len + 1);
|
||||
if (str) {
|
||||
strcat (dst, R_SYS_DIR);
|
||||
strcat (dst, str);
|
||||
dst[home_len] = R_SYS_DIR[0];
|
||||
strcpy (dst + home_len + 1, str);
|
||||
}
|
||||
fail:
|
||||
free (home);
|
||||
|
@ -1057,14 +1057,13 @@ R_API bool r_sys_tts(const char *txt, bool bg) {
|
||||
return false;
|
||||
}
|
||||
|
||||
static char prefix[128] = {0};
|
||||
|
||||
R_API const char *r_sys_prefix(const char *pfx) {
|
||||
static char prefix[1024] = {0};
|
||||
if (!*prefix) {
|
||||
r_str_ncpy (prefix, R2_PREFIX, sizeof (prefix));
|
||||
}
|
||||
if (pfx) {
|
||||
if (strlen (pfx) >= sizeof (prefix) -1) {
|
||||
if (strlen (pfx) >= sizeof (prefix) - 1) {
|
||||
return NULL;
|
||||
}
|
||||
r_str_ncpy (prefix, pfx, sizeof (prefix) - 1);
|
||||
|
Loading…
Reference in New Issue
Block a user