pidgin/pidgin

12e26d298873
Parents 6de92f3c6bdb
Children d4fd39ce339f
Set the actual number of bytes written in the win32 SIOCGIFCONF ioctl handler

Testing Done:
Sent a file from windows to linux on both xmpp and bonjour. verified only 2 interfaces were found and that bytestreams were used instead of in band.

Bugs closed: PIDGIN-17123, PIDGIN-17293, PIDGIN-17516, PIDGIN-17704

Reviewed at https://reviews.imfreedom.org/r/2018/
--- a/libpurple/win32/libc_interface.c Fri Nov 04 23:51:59 2022 -0500
+++ b/libpurple/win32/libc_interface.c Mon Nov 28 20:26:05 2022 -0600
@@ -228,9 +228,11 @@
int i;
struct ifconf *ifc = val;
char *tmp = ifc->ifc_buf;
- int nNumInterfaces =
- nBytesReturned / sizeof(INTERFACE_INFO);
- for (i = 0; i < nNumInterfaces; i++) {
+ int nReturnInterfaces = 0;
+
+ nReturnInterfaces = MIN(nBytesReturned / sizeof(INTERFACE_INFO),
+ ifc->ifc_len / sizeof(struct ifreq));
+ for (i = 0; i < nReturnInterfaces; i++) {
INTERFACE_INFO ii = InterfaceList[i];
struct ifreq *ifr = (struct ifreq *) tmp;
struct sockaddr_in *sa = (struct sockaddr_in *) &ifr->ifr_addr;
@@ -239,14 +241,9 @@
sa->sin_port = ii.iiAddress.AddressIn.sin_port;
sa->sin_addr.s_addr = ii.iiAddress.AddressIn.sin_addr.s_addr;
tmp += sizeof(struct ifreq);
-
- /* Make sure that we can fit in the original buffer */
- if (tmp >= (ifc->ifc_buf + ifc->ifc_len + sizeof(struct ifreq))) {
- break;
- }
}
/* Replace the length with the actually used length */
- ifc->ifc_len = ifc->ifc_len - (ifc->ifc_buf - tmp);
+ ifc->ifc_len = nReturnInterfaces * sizeof(struct ifreq);
return 0;
}
}