neels has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/osmo-upf/+/31272 )


Change subject: osmo-pfcp-tool: avoid stale pointers on msg copy
......................................................................

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
---
M src/osmo-pfcp-tool/pfcp_tool.c
1 file changed, 11 insertions(+), 2 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-upf refs/changes/72/31272/1

diff --git a/src/osmo-pfcp-tool/pfcp_tool.c b/src/osmo-pfcp-tool/pfcp_tool.c
index ff93cd0..ae77f64 100644
--- a/src/osmo-pfcp-tool/pfcp_tool.c
+++ b/src/osmo-pfcp-tool/pfcp_tool.c
@@ -159,13 +159,22 @@
        }
 }

+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;
 }

--
To view, visit https://gerrit.osmocom.org/c/osmo-upf/+/31272
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-upf
Gerrit-Branch: master
Gerrit-Change-Id: I4278d1c6b6da48a10d72955d9b070790d631c664
Gerrit-Change-Number: 31272
Gerrit-PatchSet: 1
Gerrit-Owner: neels <[email protected]>
Gerrit-MessageType: newchange

Reply via email to