diff options
author | Ben Pfaff <blp@nicira.com> | 2012-06-12 16:45:20 -0700 |
---|---|---|
committer | Ben Pfaff <blp@nicira.com> | 2012-06-13 08:50:22 -0700 |
commit | 03dcd8217057face1848c79e5447ea009a1abd7d (patch) | |
tree | 58426d5d378cfa4b858aecb2f5e6b4331f409610 | |
parent | 457d9df007f368bb56d0bd3c6bafacf81c93dd08 (diff) |
vlog: Avoid use-after-free in corner case.
Found by valgrind.
Signed-off-by: Ben Pfaff <blp@nicira.com>
-rw-r--r-- | lib/vlog.c | 9 |
1 files changed, 8 insertions, 1 deletions
@@ -468,6 +468,7 @@ vlog_unixctl_reopen(struct unixctl_conn *conn, int argc OVS_UNUSED, void vlog_init(void) { + static char *program_name_copy; time_t now; if (vlog_inited) { @@ -475,7 +476,13 @@ vlog_init(void) } vlog_inited = true; - openlog(program_name, LOG_NDELAY, LOG_DAEMON); + /* openlog() is allowed to keep the pointer passed in, without making a + * copy. The daemonize code sometimes frees and replaces 'program_name', + * so make a private copy just for openlog(). (We keep a pointer to the + * private copy to suppress memory leak warnings in case openlog() does + * make its own copy.) */ + program_name_copy = program_name ? xstrdup(program_name) : NULL; + openlog(program_name_copy, LOG_NDELAY, LOG_DAEMON); now = time_wall(); if (now < 0) { |