laforge has submitted this change. ( https://gerrit.osmocom.org/c/osmo-pcap/+/39773?usp=email )
Change subject: pcap-server: Validate rolling over file was successful before writing to it ......................................................................
pcap-server: Validate rolling over file was successful before writing to it
If reopening the file fails (eg. disk full), we'd end up with a null conn->wrf pointer there which would segfault in osmo_pcap_wr_file_write_msgb() immediatelly below.
Change-Id: I103d3f66bf40c68db1a20a987bc984989c91b447 --- M src/osmo_server_core.c 1 file changed, 7 insertions(+), 0 deletions(-)
Approvals: Jenkins Builder: Verified osmith: Looks good to me, but someone else must approve laforge: Looks good to me, approved
diff --git a/src/osmo_server_core.c b/src/osmo_server_core.c index cebc70a..77d916a 100644 --- a/src/osmo_server_core.c +++ b/src/osmo_server_core.c @@ -543,6 +543,13 @@ if (!check_restart_pcap_max_size(conn, msgb_length(msg))) check_restart_pcap_localtime(conn, now);
+ /* Since the checks above may have closed and re-opened (and could have + * failed), check again whether new wrf is ready... */ + if (!conn->wrf) { + LOGP(DSERVER, LOGL_ERROR, "No file is open. close connection.\n"); + return -1; + } + talloc_steal(conn->wrf, msg); rc = osmo_pcap_wr_file_write_msgb(conn->wrf, msg); if (rc < 0) {