summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeels Hofmeyr <nhofmeyr@sysmocom.de>2016-12-11 21:21:10 +0100
committerNeels Hofmeyr <nhofmeyr@sysmocom.de>2016-12-11 21:24:59 +0100
commit8fab8413bf76d47300a9d0b0f995ffe7691169b2 (patch)
tree42d15228cbdb788b8fa4f0e096ef54cd104ceabf
parent675a3cb718fa11e476fcfbe6573e58c6f5d19ae3 (diff)
NULL safety: sccp_create_sccp_addr: copy only non-NULL sock->gti
presumably, sock->gti_len is always zero when sock->gti is NULL, but ensure with a check and make coverity scan happy. Change-Id: I6cf195a3fbda1d9eacbbaec9a0e7f5b4c154f428 Fixes: coverity CID#57683
-rw-r--r--src/sccp.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/sccp.c b/src/sccp.c
index e6c538d..6c77cc4 100644
--- a/src/sccp.c
+++ b/src/sccp.c
@@ -510,8 +510,10 @@ int sccp_create_sccp_addr(struct msgb *msg, const struct sockaddr_sccp *sock)
msgb_v_put(msg, sock->sccp_ssn);
/* copy the gti if it is present */
- gti = msgb_put(msg, sock->gti_len);
- memcpy(gti, sock->gti, sock->gti_len);
+ if (sock->gti) {
+ gti = msgb_put(msg, sock->gti_len);
+ memcpy(gti, sock->gti, sock->gti_len);
+ }
/* update the length now */
len[0] = msg->tail - len - 1;