From 36a183fd7875e1d632669089ecdbd3b261ca915e Mon Sep 17 00:00:00 2001 From: Holger Hans Peter Freyther Date: Wed, 9 Nov 2016 01:45:53 +0100 Subject: client: Tolerate an invalid pcap_handle When not running as root the opening might fail and then we would crash when sending the link information. Do not crash. This could have crashed before the re-factoring but due the async connect it seems more likely we hit it now. Change-Id: I26a10c401a9a8998acc50a4bd4432d2ac7fceaeb --- src/osmo_client_network.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/osmo_client_network.c b/src/osmo_client_network.c index 4ecb1ca..2667809 100644 --- a/src/osmo_client_network.c +++ b/src/osmo_client_network.c @@ -193,6 +193,12 @@ void osmo_client_send_link(struct osmo_pcap_client_conn *conn) struct osmo_pcap_data *om_hdr; struct msgb *msg; + if (!conn->client->handle) { + LOGP(DCLIENT, LOGL_ERROR, + "No pcap_handle not sending link info to conn=%s\n", conn->name); + return; + } + msg = msgb_alloc(9000 + sizeof(*om_hdr) + sizeof(*hdr), "link-data"); if (!msg) { LOGP(DCLIENT, LOGL_ERROR, "Failed to allocate data.\n"); -- cgit v1.2.3