diff options
Diffstat (limited to 'toxcore/group.c')
-rw-r--r-- | toxcore/group.c | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/toxcore/group.c b/toxcore/group.c index c4af8fa2..5d8a6ac2 100644 --- a/toxcore/group.c +++ b/toxcore/group.c | |||
@@ -969,12 +969,12 @@ static unsigned int send_packet_group_peer(Friend_Connections *fr_c, int friendc | |||
969 | } | 969 | } |
970 | 970 | ||
971 | group_num = htons(group_num); | 971 | group_num = htons(group_num); |
972 | uint8_t packet[1 + sizeof(uint16_t) + length]; | 972 | VLA(uint8_t, packet, 1 + sizeof(uint16_t) + length); |
973 | packet[0] = packet_id; | 973 | packet[0] = packet_id; |
974 | memcpy(packet + 1, &group_num, sizeof(uint16_t)); | 974 | memcpy(packet + 1, &group_num, sizeof(uint16_t)); |
975 | memcpy(packet + 1 + sizeof(uint16_t), data, length); | 975 | memcpy(packet + 1 + sizeof(uint16_t), data, length); |
976 | return write_cryptpacket(fr_c->net_crypto, friend_connection_crypt_connection_id(fr_c, friendcon_id), packet, | 976 | return write_cryptpacket(fr_c->net_crypto, friend_connection_crypt_connection_id(fr_c, friendcon_id), packet, |
977 | sizeof(packet), 0) != -1; | 977 | SIZEOF_VLA(packet), 0) != -1; |
978 | } | 978 | } |
979 | 979 | ||
980 | /* Send a group lossy packet to friendcon_id. | 980 | /* Send a group lossy packet to friendcon_id. |
@@ -990,12 +990,12 @@ static unsigned int send_lossy_group_peer(Friend_Connections *fr_c, int friendco | |||
990 | } | 990 | } |
991 | 991 | ||
992 | group_num = htons(group_num); | 992 | group_num = htons(group_num); |
993 | uint8_t packet[1 + sizeof(uint16_t) + length]; | 993 | VLA(uint8_t, packet, 1 + sizeof(uint16_t) + length); |
994 | packet[0] = packet_id; | 994 | packet[0] = packet_id; |
995 | memcpy(packet + 1, &group_num, sizeof(uint16_t)); | 995 | memcpy(packet + 1, &group_num, sizeof(uint16_t)); |
996 | memcpy(packet + 1 + sizeof(uint16_t), data, length); | 996 | memcpy(packet + 1 + sizeof(uint16_t), data, length); |
997 | return send_lossy_cryptpacket(fr_c->net_crypto, friend_connection_crypt_connection_id(fr_c, friendcon_id), packet, | 997 | return send_lossy_cryptpacket(fr_c->net_crypto, friend_connection_crypt_connection_id(fr_c, friendcon_id), packet, |
998 | sizeof(packet)) != -1; | 998 | SIZEOF_VLA(packet)) != -1; |
999 | } | 999 | } |
1000 | 1000 | ||
1001 | #define INVITE_PACKET_SIZE (1 + sizeof(uint16_t) + GROUP_IDENTIFIER_LENGTH) | 1001 | #define INVITE_PACKET_SIZE (1 + sizeof(uint16_t) + GROUP_IDENTIFIER_LENGTH) |
@@ -1646,10 +1646,10 @@ static unsigned int send_peers(Group_Chats *g_c, int groupnumber, int friendcon_ | |||
1646 | } | 1646 | } |
1647 | 1647 | ||
1648 | if (g->title_len) { | 1648 | if (g->title_len) { |
1649 | uint8_t Packet[1 + g->title_len]; | 1649 | VLA(uint8_t, Packet, 1 + g->title_len); |
1650 | Packet[0] = PEER_TITLE_ID; | 1650 | Packet[0] = PEER_TITLE_ID; |
1651 | memcpy(Packet + 1, g->title, g->title_len); | 1651 | memcpy(Packet + 1, g->title, g->title_len); |
1652 | send_packet_group_peer(g_c->fr_c, friendcon_id, PACKET_ID_DIRECT_CONFERENCE, group_num, Packet, sizeof(Packet)); | 1652 | send_packet_group_peer(g_c->fr_c, friendcon_id, PACKET_ID_DIRECT_CONFERENCE, group_num, Packet, SIZEOF_VLA(Packet)); |
1653 | } | 1653 | } |
1654 | 1654 | ||
1655 | return sent; | 1655 | return sent; |
@@ -1902,7 +1902,7 @@ static int send_message_group(const Group_Chats *g_c, int groupnumber, uint8_t m | |||
1902 | return -3; | 1902 | return -3; |
1903 | } | 1903 | } |
1904 | 1904 | ||
1905 | uint8_t packet[sizeof(uint16_t) + sizeof(uint32_t) + 1 + len]; | 1905 | VLA(uint8_t, packet, sizeof(uint16_t) + sizeof(uint32_t) + 1 + len); |
1906 | uint16_t peer_num = htons(g->peer_number); | 1906 | uint16_t peer_num = htons(g->peer_number); |
1907 | memcpy(packet, &peer_num, sizeof(peer_num)); | 1907 | memcpy(packet, &peer_num, sizeof(peer_num)); |
1908 | 1908 | ||
@@ -1921,7 +1921,7 @@ static int send_message_group(const Group_Chats *g_c, int groupnumber, uint8_t m | |||
1921 | memcpy(packet + sizeof(uint16_t) + sizeof(uint32_t) + 1, data, len); | 1921 | memcpy(packet + sizeof(uint16_t) + sizeof(uint32_t) + 1, data, len); |
1922 | } | 1922 | } |
1923 | 1923 | ||
1924 | unsigned int ret = send_message_all_close(g_c, groupnumber, packet, sizeof(packet), -1); | 1924 | unsigned int ret = send_message_all_close(g_c, groupnumber, packet, SIZEOF_VLA(packet), -1); |
1925 | 1925 | ||
1926 | return (ret == 0) ? -4 : ret; | 1926 | return (ret == 0) ? -4 : ret; |
1927 | } | 1927 | } |
@@ -1970,14 +1970,14 @@ int send_group_lossy_packet(const Group_Chats *g_c, int groupnumber, const uint8 | |||
1970 | return -1; | 1970 | return -1; |
1971 | } | 1971 | } |
1972 | 1972 | ||
1973 | uint8_t packet[sizeof(uint16_t) * 2 + length]; | 1973 | VLA(uint8_t, packet, sizeof(uint16_t) * 2 + length); |
1974 | uint16_t peer_number = htons(g->peer_number); | 1974 | uint16_t peer_number = htons(g->peer_number); |
1975 | memcpy(packet, &peer_number, sizeof(uint16_t)); | 1975 | memcpy(packet, &peer_number, sizeof(uint16_t)); |
1976 | uint16_t message_num = htons(g->lossy_message_number); | 1976 | uint16_t message_num = htons(g->lossy_message_number); |
1977 | memcpy(packet + sizeof(uint16_t), &message_num, sizeof(uint16_t)); | 1977 | memcpy(packet + sizeof(uint16_t), &message_num, sizeof(uint16_t)); |
1978 | memcpy(packet + sizeof(uint16_t) * 2, data, length); | 1978 | memcpy(packet + sizeof(uint16_t) * 2, data, length); |
1979 | 1979 | ||
1980 | if (send_lossy_all_close(g_c, groupnumber, packet, sizeof(packet), -1) == 0) { | 1980 | if (send_lossy_all_close(g_c, groupnumber, packet, SIZEOF_VLA(packet), -1) == 0) { |
1981 | return -1; | 1981 | return -1; |
1982 | } | 1982 | } |
1983 | 1983 | ||
@@ -2088,7 +2088,7 @@ static void handle_message_packet_group(Group_Chats *g_c, int groupnumber, const | |||
2088 | return; | 2088 | return; |
2089 | } | 2089 | } |
2090 | 2090 | ||
2091 | uint8_t newmsg[msg_data_len + 1]; | 2091 | VLA(uint8_t, newmsg, msg_data_len + 1); |
2092 | memcpy(newmsg, msg_data, msg_data_len); | 2092 | memcpy(newmsg, msg_data, msg_data_len); |
2093 | newmsg[msg_data_len] = 0; | 2093 | newmsg[msg_data_len] = 0; |
2094 | 2094 | ||
@@ -2105,7 +2105,7 @@ static void handle_message_packet_group(Group_Chats *g_c, int groupnumber, const | |||
2105 | return; | 2105 | return; |
2106 | } | 2106 | } |
2107 | 2107 | ||
2108 | uint8_t newmsg[msg_data_len + 1]; | 2108 | VLA(uint8_t, newmsg, msg_data_len + 1); |
2109 | memcpy(newmsg, msg_data, msg_data_len); | 2109 | memcpy(newmsg, msg_data, msg_data_len); |
2110 | newmsg[msg_data_len] = 0; | 2110 | newmsg[msg_data_len] = 0; |
2111 | 2111 | ||