Change in osmo-mgw[master]: protocol: prevent unnecessary null pointer deref

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

dexter gerrit-no-reply at lists.osmocom.org
Thu Jul 19 16:20:48 UTC 2018


dexter has uploaded this change for review. ( https://gerrit.osmocom.org/10055


Change subject: protocol: prevent unnecessary null pointer deref
......................................................................

protocol: prevent unnecessary null pointer deref

The function setup_rtp_processing() in mgcp_protocol.c executes a
function pointer setup_rtp_processing_cb(). The function pointer
gets two struct mgcp_rtp_end pointers as parameter. To get those
parameters it has to dereference them from struct mgcp_conn_rtp
pointers. The variable conn_src is such a struct pointer and there
are conditions where this pointer may be NULL. The function at the
function pointer should get the conn pointers directly instead of
the dereferenced end (rtp) pointers. This also gives additional
flexibility to the implementation behind the function pointer,
which is not yet defined (the function pointer points always to
a stub function since we donot support transcoding yet.

- give conn pointers directly to setup_rtp_processing_cb() insed
  of dereferencing conn_src->end

Change-Id: Id46e9bfba88613387026639eb4957221cce6820a
Closes OS#3406
---
M include/osmocom/mgcp/mgcp.h
M include/osmocom/mgcp/mgcp_internal.h
M src/libosmo-mgcp/mgcp_network.c
M src/libosmo-mgcp/mgcp_protocol.c
4 files changed, 12 insertions(+), 11 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-mgw refs/changes/55/10055/1

diff --git a/include/osmocom/mgcp/mgcp.h b/include/osmocom/mgcp/mgcp.h
index bdc8f87..bdc86fc 100644
--- a/include/osmocom/mgcp/mgcp.h
+++ b/include/osmocom/mgcp/mgcp.h
@@ -74,11 +74,13 @@
 typedef int (*mgcp_processing)(struct mgcp_endpoint *endp,
 			       struct mgcp_rtp_end *dst_end,
 			       char *data, int *len, int buf_size);
-typedef int (*mgcp_processing_setup)(struct mgcp_endpoint *endp,
-				     struct mgcp_rtp_end *dst_end,
-				     struct mgcp_rtp_end *src_end);
 
 struct mgcp_conn_rtp;
+
+typedef int (*mgcp_processing_setup)(struct mgcp_endpoint *endp,
+				     struct mgcp_conn_rtp *conn_dst,
+				     struct mgcp_conn_rtp *conn_src);
+
 typedef void (*mgcp_get_format)(struct mgcp_endpoint *endp,
 				int *payload_type,
 				const char**subtype_name,
diff --git a/include/osmocom/mgcp/mgcp_internal.h b/include/osmocom/mgcp/mgcp_internal.h
index 38b687c..06883dd 100644
--- a/include/osmocom/mgcp/mgcp_internal.h
+++ b/include/osmocom/mgcp/mgcp_internal.h
@@ -290,8 +290,8 @@
 				char *data, int *len, int buf_size);
 
 int mgcp_setup_rtp_processing_default(struct mgcp_endpoint *endp,
-				      struct mgcp_rtp_end *dst_end,
-				      struct mgcp_rtp_end *src_end);
+				      struct mgcp_conn_rtp *conn_dst,
+				      struct mgcp_conn_rtp *conn_src);
 
 void mgcp_get_net_downlink_format_default(struct mgcp_endpoint *endp,
 					  int *payload_type,
diff --git a/src/libosmo-mgcp/mgcp_network.c b/src/libosmo-mgcp/mgcp_network.c
index 494156d..870a4de 100644
--- a/src/libosmo-mgcp/mgcp_network.c
+++ b/src/libosmo-mgcp/mgcp_network.c
@@ -399,12 +399,12 @@
 
 /*! dummy callback to disable transcoding (see also cfg->setup_rtp_processing_cb).
  *  \param[in] associated endpoint
- *  \param[in] destination RTP end
- *  \param[in] source RTP end
+ *  \param[in] destination RTP connnection
+ *  \param[in] source RTP connection
  *  \returns ignores input parameters, return always 0 */
 int mgcp_setup_rtp_processing_default(struct mgcp_endpoint *endp,
-				      struct mgcp_rtp_end *dst_end,
-				      struct mgcp_rtp_end *src_end)
+				      struct mgcp_conn_rtp *conn_dst,
+				      struct mgcp_conn_rtp *conn_src)
 {
 	LOGP(DRTP, LOGL_DEBUG, "endpoint:0x%x transcoding disabled\n",
 	     ENDPOINT_NUMBER(endp));
diff --git a/src/libosmo-mgcp/mgcp_protocol.c b/src/libosmo-mgcp/mgcp_protocol.c
index eea67a6..ea80907 100644
--- a/src/libosmo-mgcp/mgcp_protocol.c
+++ b/src/libosmo-mgcp/mgcp_protocol.c
@@ -89,8 +89,7 @@
 		}
 	}
 
-	return cfg->setup_rtp_processing_cb(endp, &conn_dst->end,
-					    &conn_src->end);
+	return cfg->setup_rtp_processing_cb(endp, conn_dst, conn_src);
 }
 
 /* array of function pointers for handling various

-- 
To view, visit https://gerrit.osmocom.org/10055
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-mgw
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: Id46e9bfba88613387026639eb4957221cce6820a
Gerrit-Change-Number: 10055
Gerrit-PatchSet: 1
Gerrit-Owner: dexter <pmaier at sysmocom.de>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20180719/77be546e/attachment.htm>


More information about the gerrit-log mailing list