mirror of
https://github.com/irungentoo/toxcore.git
synced 2024-03-22 13:30:51 +08:00
Fixed possible bug.
This commit is contained in:
parent
9303c18b0c
commit
be06888517
|
@ -42,6 +42,7 @@ static void fetch_broadcast_info(uint16_t port)
|
|||
*/
|
||||
broadcast_count = 0;
|
||||
sock_t sock = 0;
|
||||
|
||||
if ((sock = socket(AF_INET, SOCK_STREAM, 0)) < 0)
|
||||
return;
|
||||
|
||||
|
@ -64,6 +65,7 @@ static void fetch_broadcast_info(uint16_t port)
|
|||
* enough, for everybody!)
|
||||
*/
|
||||
int i, count = ifconf.ifc_len / sizeof(struct ifreq);
|
||||
|
||||
for (i = 0; i < count; i++) {
|
||||
/* there are interfaces with are incapable of broadcast */
|
||||
if (ioctl(sock, SIOCGIFBRDADDR, &i_faces[i]) < 0)
|
||||
|
@ -74,6 +76,10 @@ static void fetch_broadcast_info(uint16_t port)
|
|||
continue;
|
||||
|
||||
struct sockaddr_in *sock4 = (struct sockaddr_in *)&i_faces[i].ifr_broadaddr;
|
||||
|
||||
if (broadcast_count >= MAX_INTERFACES)
|
||||
return;
|
||||
|
||||
IP_Port *ip_port = &broadcast_ip_port[broadcast_count];
|
||||
ip_port->ip.family = AF_INET;
|
||||
ip_port->ip.ip4.in_addr = sock4->sin_addr;
|
||||
|
|
Loading…
Reference in New Issue
Block a user