@miconda regarding this change:
```
-                       *from = &si->su;
+                       memcpy(*from, &si->su, sockaddru_len(si->su));
```

At [this 
line](https://github.com/kamailio/kamailio/pull/3925/files#diff-aee8567648ae9f54eaf1f7a0feb3302d981966a749b16710e2b457da7c22c412R1306)
 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](https://github.com/kamailio/kamailio/pull/3925/files#diff-aee8567648ae9f54eaf1f7a0feb3302d981966a749b16710e2b457da7c22c412R1318)
 it will be re-written with new port, which linux kernel has allocated for this 
sockaddr_union as a result of [this bind 
invocation](https://github.com/kamailio/kamailio/pull/3925/files#diff-aee8567648ae9f54eaf1f7a0feb3302d981966a749b16710e2b457da7c22c412R1309),
 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 or view it on GitHub:
https://github.com/kamailio/kamailio/pull/3925#issuecomment-2236541862
You are receiving this because you are subscribed to this thread.

Message ID: <kamailio/kamailio/pull/3925/c2236541...@github.com>
_______________________________________________
Kamailio (SER) - Development Mailing List
To unsubscribe send an email to sr-dev-le...@lists.kamailio.org

Reply via email to