snprintf is better
This commit is contained in:
parent
9cd5742bec
commit
ab62a84790
@ -512,7 +512,7 @@ char **rc_filter_env (void)
|
|||||||
got_path = true;
|
got_path = true;
|
||||||
env_len = strlen (env_name) + strlen (env_var) + pplen + 2;
|
env_len = strlen (env_name) + strlen (env_var) + pplen + 2;
|
||||||
e = p = rc_xmalloc (sizeof (char *) * env_len);
|
e = p = rc_xmalloc (sizeof (char *) * env_len);
|
||||||
p += sprintf (e, "%s=%s", env_name, PATH_PREFIX);
|
p += snprintf (e, env_len, "%s=%s", env_name, PATH_PREFIX);
|
||||||
|
|
||||||
/* Now go through the env var and only add bits not in our PREFIX */
|
/* Now go through the env var and only add bits not in our PREFIX */
|
||||||
sep = env_var;
|
sep = env_var;
|
||||||
@ -525,7 +525,7 @@ char **rc_filter_env (void)
|
|||||||
if (strcmp (tok, token) == 0)
|
if (strcmp (tok, token) == 0)
|
||||||
break;
|
break;
|
||||||
if (! tok)
|
if (! tok)
|
||||||
p += sprintf (p, ":%s", token);
|
p += snprintf (p, env_len - (p - e), ":%s", token);
|
||||||
free (np);
|
free (np);
|
||||||
}
|
}
|
||||||
*p++ = 0;
|
*p++ = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user