Browse code

sctp: memcpy field data to avoid unaligned access warning

- GH #2543

Daniel-Constantin Mierla authored on 09/11/2020 12:10:43
Showing 1 changed files
... ...
@@ -2258,6 +2258,7 @@ static int sctp_handle_notification(struct socket_info *si,
2258 2258
 {
2259 2259
 	union sctp_notification *snp;
2260 2260
 	char su_buf[SU2A_MAX_STR_SIZE];
2261
+	struct sockaddr_storage sa_storage;
2261 2262
 
2262 2263
 #define SNOT DBG
2263 2264
 #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,
2311 2312
 					sctp_paddr_change_state2s(snp->sn_paddr_change.spc_state),
2312 2313
 					snp->sn_paddr_change.spc_state,
2313 2314
 					&snp->sn_paddr_change.spc_aaddr);
2314
-			strcpy(su_buf, su2a((union sockaddr_union *)&snp->sn_paddr_change
2315
-										   .spc_aaddr,
2315
+			memcpy(&sa_storage, &snp->sn_paddr_change.spc_aaddr,
2316
+					sizeof(snp->sn_paddr_change.spc_aaddr));
2317
+			strcpy(su_buf, su2a((union sockaddr_union *)&sa_storage,
2316 2318
 								   sizeof(snp->sn_paddr_change.spc_aaddr)));
2317 2319
 			SNOT("sctp notification from %s on %.*s:%d: SCTP_PEER_ADDR_CHANGE"
2318 2320
 				 ": %s: %s: assoc_id %d \n",