osmo-pfcp-tool: avoid stale pointers on msg copy

Upon copying a PFCP msg struct for the 'retrans' command, make sure the
copy has no pointers that may go stale.

Change-Id: I4278d1c6b6da48a10d72955d9b070790d631c664
This commit is contained in:
Neels Janosch Hofmeyr
2023-02-09 00:10:42 +01:00
parent 3c0fc60c3c
commit 374fd1eab4

View File

@@ -159,13 +159,22 @@ void pfcp_tool_rx_msg(struct osmo_pfcp_endpoint *ep, struct osmo_pfcp_msg *m, st
}
}
static void copy_msg(struct osmo_pfcp_msg *dst, const struct osmo_pfcp_msg *m)
{
*dst = *m;
dst->encoded = NULL;
dst->ctx.peer_use_token = NULL;
dst->ctx.session_use_token = NULL;
dst->ctx.resp_cb = NULL;
}
int peer_tx(struct pfcp_tool_peer *peer, struct osmo_pfcp_msg *m)
{
int rc;
if (m->is_response)
peer->last_resp = *m;
copy_msg(&peer->last_resp, m);
else
peer->last_req = *m;
copy_msg(&peer->last_req, m);
rc = osmo_pfcp_endpoint_tx(g_pfcp_tool->ep, m);
return rc;
}