mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-11-10 03:16:17 +01:00
Another fix on g_socket_send_message()
We forgot to take into account the case where num_vectors is '-1'.
This commit is contained in:
parent
5f11206237
commit
b6f7e4678b
@ -4784,7 +4784,9 @@ g_socket_send_message (GSocket *socket,
|
||||
gsize bytes_written = 0;
|
||||
gsize vectors_size = 0;
|
||||
|
||||
for (gsize i = 0; i < num_vectors; i++)
|
||||
if (num_vectors != -1)
|
||||
{
|
||||
for (gint i = 0; i < num_vectors; i++)
|
||||
{
|
||||
/* No wrap-around for vectors_size */
|
||||
if (vectors_size > vectors_size + vectors[i].size)
|
||||
@ -4797,6 +4799,23 @@ g_socket_send_message (GSocket *socket,
|
||||
|
||||
vectors_size += vectors[i].size;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (gsize i = 0; vectors[i].buffer != NULL; i++)
|
||||
{
|
||||
/* No wrap-around for vectors_size */
|
||||
if (vectors_size > vectors_size + vectors[i].size)
|
||||
{
|
||||
g_set_error (error, G_IO_ERROR, G_IO_ERROR_INVALID_ARGUMENT,
|
||||
_("Unable to send message: %s"),
|
||||
_("Message vectors too large"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
vectors_size += vectors[i].size;
|
||||
}
|
||||
}
|
||||
|
||||
/* Check if vector's buffers are too big for gssize */
|
||||
if (vectors_size > G_MAXSSIZE)
|
||||
|
Loading…
Reference in New Issue
Block a user