diff options
author | Ben Pfaff <blp@nicira.com> | 2012-01-31 09:39:28 -0800 |
---|---|---|
committer | Ben Pfaff <blp@nicira.com> | 2012-01-31 13:08:42 -0800 |
commit | 833aa7f8a376b274a6e50bbf2323d6ae4a25914f (patch) | |
tree | ce251fce519d6604f6701431bc0d0a9f2973d888 | |
parent | 45838d33779f8b590c6b1ab8a78d77998f82e24d (diff) | |
download | openvswitch-833aa7f8a376b274a6e50bbf2323d6ae4a25914f.tar.gz |
sflow_agent: Use snprintf() in place of sprintf().
These functions use sprintf() into a 1000-byte buffer. It appears to me
that the strings they format are either short, fixed-length strings or the
output of strerror(), neither of which should ordinarily overflow.
However, using snprintf() cannot hurt.
Launchpad bug #914160.
Reported-by: Matthias Klose <doko@ubuntu.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
-rw-r--r-- | lib/sflow_agent.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/sflow_agent.c b/lib/sflow_agent.c index ba8d2bf99..0e90c3ff8 100644 --- a/lib/sflow_agent.c +++ b/lib/sflow_agent.c @@ -449,7 +449,7 @@ void sfl_agent_resetReceiver(SFLAgent *agent, SFLReceiver *receiver) void sfl_agent_error(SFLAgent *agent, char *modName, char *msg) { char errm[MAX_ERRMSG_LEN]; - sprintf(errm, "sfl_agent_error: %s: %s\n", modName, msg); + snprintf(errm, sizeof errm, "sfl_agent_error: %s: %s\n", modName, msg); if(agent->errorFn) (*agent->errorFn)(agent->magic, agent, errm); else { fprintf(stderr, "%s\n", errm); @@ -465,7 +465,7 @@ void sfl_agent_error(SFLAgent *agent, char *modName, char *msg) void sfl_agent_sysError(SFLAgent *agent, char *modName, char *msg) { char errm[MAX_ERRMSG_LEN]; - sprintf(errm, "sfl_agent_sysError: %s: %s (errno = %d - %s)\n", modName, msg, errno, strerror(errno)); + snprintf(errm, sizeof errm, "sfl_agent_sysError: %s: %s (errno = %d - %s)\n", modName, msg, errno, strerror(errno)); if(agent->errorFn) (*agent->errorFn)(agent->magic, agent, errm); else { fprintf(stderr, "%s\n", errm); |