[sr-dev] git:master:7c795ada: pdb: avoid unaligned pointer address

Daniel-Constantin Mierla miconda at gmail.com
Fri Jul 14 14:26:40 CEST 2017


Module: kamailio
Branch: master
Commit: 7c795adaf0f3899567a9769fecbbb300387837be
URL: https://github.com/kamailio/kamailio/commit/7c795adaf0f3899567a9769fecbbb300387837be

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2017-07-14T14:25:57+02:00

pdb: avoid unaligned pointer address

---

Modified: src/modules/pdb/pdb.c

---

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

---

diff --git a/src/modules/pdb/pdb.c b/src/modules/pdb/pdb.c
index 3142ba26f9..e4ef6758d9 100644
--- a/src/modules/pdb/pdb.c
+++ b/src/modules/pdb/pdb.c
@@ -198,6 +198,7 @@ static int pdb_query(struct sip_msg *_msg, struct multiparam_t *_number, struct
 	struct timeval tstart, tnow;
 	struct server_item_t *server;
 	short int carrierid, *_id;
+	short int _idv;
     char buf[sizeof(struct pdb_msg)];
 	size_t reqlen;
 	int_str avp_val;
@@ -324,7 +325,7 @@ static int pdb_query(struct sip_msg *_msg, struct multiparam_t *_number, struct
 			}
 			return -1;
 		}
-		
+
 		ret=poll(server_list->fds, server_list->nserver, timeout-td);
 		for (i=0; i<server_list->nserver; i++) {
 			if (server_list->fds[i].revents & POLLIN) {
@@ -334,8 +335,8 @@ static int pdb_query(struct sip_msg *_msg, struct multiparam_t *_number, struct
                             memcpy(&msg, buf, bytes_received);
                             pdb_msg_dbg(msg, "Kamailio pdb client receives:");
 
-                            _id = (short int *)&(msg.hdr.id); /* make gcc happy */
-                            msg.hdr.id = ntohs(*_id);
+                            _idv = msg.hdr.id; /* make gcc happy */
+                            msg.hdr.id = ntohs(_idv);
 
                             switch (msg.hdr.code) {
                                 case PDB_CODE_OK:




More information about the sr-dev mailing list