diff options
author | Daniel Willmann <daniel@totalueberwachung.de> | 2011-07-17 17:48:17 +0200 |
---|---|---|
committer | Holger Hans Peter Freyther <zecke@selfish.org> | 2011-07-19 17:56:03 +0200 |
commit | de77386d84f8d9237020bc5d12ef51b754cb7563 (patch) | |
tree | 8bba5a447e91fe52760755c1d842bfb227cadff5 | |
parent | f60990e3f41b684e45113a6339dd2e7adfecc434 (diff) |
server: Fix memory leak and error handling in restart_pcap
-rw-r--r-- | src/osmo_server_network.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/osmo_server_network.c b/src/osmo_server_network.c index 121aa2c..be61d03 100644 --- a/src/osmo_server_network.c +++ b/src/osmo_server_network.c @@ -62,14 +62,20 @@ static void restart_pcap(struct osmo_pcap_conn *conn) conn->local_fd = -1; } - filename = talloc_asprintf(conn, "%s/trace-%s-%d%.2d%.2d_%.2d%.2d%.2d.pcap", conn->server->base_path, conn->name, tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec); + + if (!filename) { + LOGP(DSERVER, LOGL_ERROR, "Failed to assemble filename for %s.\n", conn->name); + return; + } + conn->local_fd = creat(filename, 0440); if (conn->local_fd < 0) { LOGP(DSERVER, LOGL_ERROR, "Failed to file: '%s'\n", filename); + talloc_free(filename); return; } @@ -78,6 +84,7 @@ static void restart_pcap(struct osmo_pcap_conn *conn) LOGP(DSERVER, LOGL_ERROR, "Failed to write the header: %d\n", errno); close(conn->local_fd); conn->local_fd = -1; + talloc_free(filename); return; } |