@miconda regarding this change:

-			*from = &si->su;
+			memcpy(*from, &si->su, sockaddru_len(si->su));

At this line the port is changed for the *from, which is the pointer to the object of union sockaddr_union.
If we don't use a hard copy and just use pointers then the port for si->su will be re-written to zero, and then at this line it will be re-written with new port, which linux kernel has allocated for this sockaddr_union as a result of this bind invocation, but si->su is the sockaddr_union object for kamailio listening socket. So if we don't use hard copy here then we will replace sockaddr_union object for listening socket with the data for another socket.

As for sockaddru_len usage - If I'm not wrong this macro reflects the size of union sockaddr_union

/* len of the sockaddr */
#ifdef HAVE_SOCKADDR_SA_LEN
#define sockaddru_len(su) ((su).s.sa_len)
#else
#define sockaddru_len(su)                                         \
	(((su).s.sa_family == AF_INET6) ? sizeof(struct sockaddr_in6) \
					: sizeof(struct sockaddr_in))
#endif /* HAVE_SOCKADDR_SA_LEN*/

Please let us know if you suggest to get the size by some other approach.


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <kamailio/kamailio/pull/3925/c2236541862@github.com>