[sr-dev] git:master:1296bb22: core: pad some fields in contained structs for 4 byte alignment

Daniel-Constantin Mierla miconda at gmail.com
Mon Oct 28 10:02:07 CET 2019


Module: kamailio
Branch: master
Commit: 1296bb2270985a1bf3af04f35e4cdae1fe4b184a
URL: https://github.com/kamailio/kamailio/commit/1296bb2270985a1bf3af04f35e4cdae1fe4b184a

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2019-10-28T10:00:28+01:00

core: pad some fields in contained structs for 4 byte alignment

- safety for sigbus on strict cpu architectures when accesing fields by
address

---

Modified: src/core/ip_addr.h

---

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

---

diff --git a/src/core/ip_addr.h b/src/core/ip_addr.h
index afbaece075..0d26e7e756 100644
--- a/src/core/ip_addr.h
+++ b/src/core/ip_addr.h
@@ -91,6 +91,7 @@ typedef struct addr_info {
 typedef struct advertise_info {
 	str name; /* name - eg.: foo.bar or 10.0.0.1 */
 	unsigned short port_no;  /* port number */
+	short port_pad; /* padding field */
 	str port_no_str; /* port number converted to string -- optimization*/
 	str address_str;        /*ip address converted to string -- optimization*/
 	struct ip_addr address; /* ip address */
@@ -109,6 +110,8 @@ typedef struct socket_info {
 	struct socket_info* prev;
 	unsigned short port_no;  /* port number */
 	char proto; /* tcp or udp*/
+	char proto_pad0; /* padding field */
+	short proto_pad1; /* padding field */
 	str sock_str; /* Socket proto, ip, and port as string */
 	struct addr_info* addr_info_lst; /* extra addresses (e.g. SCTP mh) */
 	int workers; /* number of worker processes for this socket */
@@ -143,7 +146,11 @@ typedef struct receive_info {
 										* the msg was received */
 	char proto;
 #ifdef USE_COMP
+	char proto_pad0;  /* padding field */
 	short comp; /* compression */
+#else
+	char proto_pad0;  /* padding field */
+	short proto_pad1; /* padding field */
 #endif
 	/* no need for dst_su yet */
 } receive_info_t;
@@ -153,10 +160,14 @@ typedef struct dest_info {
 	struct socket_info* send_sock;
 	union sockaddr_union to;
 	int id; /* tcp stores the connection id here */
-	char proto;
 	snd_flags_t send_flags;
+	char proto;
 #ifdef USE_COMP
+	char proto_pad0;  /* padding field */
 	short comp;
+#else
+	char proto_pad0;  /* padding field */
+	short proto_pad1; /* padding field */
 #endif
 } dest_info_t;
 




More information about the sr-dev mailing list