From ab62a84790950cbc321b9251197b332461f480c6 Mon Sep 17 00:00:00 2001 From: Roy Marples Date: Fri, 6 Apr 2007 08:37:15 +0000 Subject: [PATCH] snprintf is better --- src/librc-misc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/librc-misc.c b/src/librc-misc.c index 75df0455..9cfd925f 100644 --- a/src/librc-misc.c +++ b/src/librc-misc.c @@ -512,7 +512,7 @@ char **rc_filter_env (void) got_path = true; env_len = strlen (env_name) + strlen (env_var) + pplen + 2; 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 */ sep = env_var; @@ -525,7 +525,7 @@ char **rc_filter_env (void) if (strcmp (tok, token) == 0) break; if (! tok) - p += sprintf (p, ":%s", token); + p += snprintf (p, env_len - (p - e), ":%s", token); free (np); } *p++ = 0;