Harald Welte has submitted this change and it was merged. ( 
https://gerrit.osmocom.org/11403 )

Change subject: check_rtp_origin(): Avoid using memcmp for comparing integer 
types
......................................................................

check_rtp_origin(): Avoid using memcmp for comparing integer types

in_addr consists only of s_addr, which is an integer type that
can be compared directly.  By avoiding memcmp() here we would have
been able to catch Coverity CID#188874 even without Coverity, and
make the code more compact...

Change-Id: Ic6105d39ae2fb4b301f87448b16763fe9f695621
---
M src/libosmo-mgcp/mgcp_network.c
1 file changed, 2 insertions(+), 4 deletions(-)

Approvals:
  Jenkins Builder: Verified
  Harald Welte: Looks good to me, approved



diff --git a/src/libosmo-mgcp/mgcp_network.c b/src/libosmo-mgcp/mgcp_network.c
index fe63f1e..de34cc6 100644
--- a/src/libosmo-mgcp/mgcp_network.c
+++ b/src/libosmo-mgcp/mgcp_network.c
@@ -872,9 +872,8 @@
 {
        struct mgcp_endpoint *endp;
        endp = conn->conn->endp;
-       struct sockaddr_in zero_addr = {};

-       if (memcmp(&zero_addr.sin_addr, &conn->end.addr, 
sizeof(zero_addr.sin_addr)) == 0) {
+       if (conn->end.addr.s_addr == 0) {
                switch (conn->conn->mode) {
                case MGCP_CONN_LOOPBACK:
                        /* HACK: for IuUP, we want to reply with an IuUP 
Initialization ACK upon the first RTP
@@ -904,8 +903,7 @@

        /* Note: Check if the inbound RTP data comes from the same host to
         * which we send our outgoing RTP traffic. */
-       if (memcmp(&addr->sin_addr, &conn->end.addr, sizeof(addr->sin_addr))
-           != 0) {
+       if (conn->end.addr.s_addr != addr->sin_addr.s_addr) {
                LOGP(DRTP, LOGL_ERROR,
                     "endpoint:0x%x data from wrong address: %s, ",
                     ENDPOINT_NUMBER(endp), inet_ntoa(addr->sin_addr));

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

Gerrit-Project: osmo-mgw
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: Ic6105d39ae2fb4b301f87448b16763fe9f695621
Gerrit-Change-Number: 11403
Gerrit-PatchSet: 1
Gerrit-Owner: Harald Welte <[email protected]>
Gerrit-Reviewer: Harald Welte <[email protected]>
Gerrit-Reviewer: Jenkins Builder (1000002)

Reply via email to