[sr-dev] git:5.4:f6747a1f: sctp: memcpy field data to avoid unaligned access warning

Daniel-Constantin Mierla miconda at gmail.com
Thu Nov 19 13:41:01 CET 2020


Module: kamailio
Branch: 5.4
Commit: f6747a1fe4af59062733090ee0081d1bf15669c3
URL: https://github.com/kamailio/kamailio/commit/f6747a1fe4af59062733090ee0081d1bf15669c3

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2020-11-19T13:27:02+01:00

sctp: memcpy field data to avoid unaligned access warning

- GH #2543

(cherry picked from commit 4bb099b046939b85e1827b804167a51ef4bc00c4)

---

Modified: src/modules/sctp/sctp_server.c

---

Diff:  https://github.com/kamailio/kamailio/commit/f6747a1fe4af59062733090ee0081d1bf15669c3.diff
Patch: https://github.com/kamailio/kamailio/commit/f6747a1fe4af59062733090ee0081d1bf15669c3.patch

---

diff --git a/src/modules/sctp/sctp_server.c b/src/modules/sctp/sctp_server.c
index 6690503973..fff7a0b6b3 100644
--- a/src/modules/sctp/sctp_server.c
+++ b/src/modules/sctp/sctp_server.c
@@ -2258,6 +2258,7 @@ static int sctp_handle_notification(struct socket_info *si,
 {
 	union sctp_notification *snp;
 	char su_buf[SU2A_MAX_STR_SIZE];
+	struct sockaddr_storage sa_storage;
 
 #define SNOT DBG
 #define ERR_LEN_TOO_SMALL(length, val, bind_addr, from_su, text)            \
@@ -2311,8 +2312,9 @@ static int sctp_handle_notification(struct socket_info *si,
 					sctp_paddr_change_state2s(snp->sn_paddr_change.spc_state),
 					snp->sn_paddr_change.spc_state,
 					&snp->sn_paddr_change.spc_aaddr);
-			strcpy(su_buf, su2a((union sockaddr_union *)&snp->sn_paddr_change
-										   .spc_aaddr,
+			memcpy(&sa_storage, &snp->sn_paddr_change.spc_aaddr,
+					sizeof(snp->sn_paddr_change.spc_aaddr));
+			strcpy(su_buf, su2a((union sockaddr_union *)&sa_storage,
 								   sizeof(snp->sn_paddr_change.spc_aaddr)));
 			SNOT("sctp notification from %s on %.*s:%d: SCTP_PEER_ADDR_CHANGE"
 				 ": %s: %s: assoc_id %d \n",




More information about the sr-dev mailing list