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
This commit is contained in:
parent
bca0ef6cd9
commit
acc10353fe
|
@ -74,11 +74,13 @@ typedef int (*mgcp_rqnt)(struct mgcp_endpoint *endp, char tone);
|
|||
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,
|
||||
|
|
|
@ -290,8 +290,8 @@ int mgcp_rtp_processing_default(struct mgcp_endpoint *endp, struct mgcp_rtp_end
|
|||
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,
|
||||
|
|
|
@ -399,12 +399,12 @@ int mgcp_rtp_processing_default(struct mgcp_endpoint *endp,
|
|||
|
||||
/*! 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));
|
||||
|
|
|
@ -89,8 +89,7 @@ static int setup_rtp_processing(struct mgcp_endpoint *endp,
|
|||
}
|
||||
}
|
||||
|
||||
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
|
||||
|
|
Loading…
Reference in New Issue