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;
|
broadcast_count = 0;
|
||||||
sock_t sock = 0;
|
sock_t sock = 0;
|
||||||
|
|
||||||
if ((sock = socket(AF_INET, SOCK_STREAM, 0)) < 0)
|
if ((sock = socket(AF_INET, SOCK_STREAM, 0)) < 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -64,6 +65,7 @@ static void fetch_broadcast_info(uint16_t port)
|
||||||
* enough, for everybody!)
|
* enough, for everybody!)
|
||||||
*/
|
*/
|
||||||
int i, count = ifconf.ifc_len / sizeof(struct ifreq);
|
int i, count = ifconf.ifc_len / sizeof(struct ifreq);
|
||||||
|
|
||||||
for (i = 0; i < count; i++) {
|
for (i = 0; i < count; i++) {
|
||||||
/* there are interfaces with are incapable of broadcast */
|
/* there are interfaces with are incapable of broadcast */
|
||||||
if (ioctl(sock, SIOCGIFBRDADDR, &i_faces[i]) < 0)
|
if (ioctl(sock, SIOCGIFBRDADDR, &i_faces[i]) < 0)
|
||||||
|
@ -74,6 +76,10 @@ static void fetch_broadcast_info(uint16_t port)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
struct sockaddr_in *sock4 = (struct sockaddr_in *)&i_faces[i].ifr_broadaddr;
|
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_port = &broadcast_ip_port[broadcast_count];
|
||||||
ip_port->ip.family = AF_INET;
|
ip_port->ip.family = AF_INET;
|
||||||
ip_port->ip.ip4.in_addr = sock4->sin_addr;
|
ip_port->ip.ip4.in_addr = sock4->sin_addr;
|
||||||
|
@ -101,7 +107,7 @@ static uint32_t send_broadcasts(Networking_Core *net, uint16_t port, uint8_t *da
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for(i = 0; i < broadcast_count; i++)
|
for (i = 0; i < broadcast_count; i++)
|
||||||
sendpacket(net, broadcast_ip_port[i], data, 1 + crypto_box_PUBLICKEYBYTES);
|
sendpacket(net, broadcast_ip_port[i], data, 1 + crypto_box_PUBLICKEYBYTES);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user