Merge branch 'fix__g_socket_send_message_again' into 'master'

Another fix on g_socket_send_message()

See merge request GNOME/glib!1878
This commit is contained in:
Sebastian Dröge 2021-01-13 14:35:29 +00:00
commit 4c3bce84d6

View File

@ -4784,18 +4784,37 @@ g_socket_send_message (GSocket *socket,
gsize bytes_written = 0; gsize bytes_written = 0;
gsize vectors_size = 0; gsize vectors_size = 0;
for (gsize i = 0; i < num_vectors; i++) if (num_vectors != -1)
{ {
/* No wrap-around for vectors_size */ for (gint i = 0; i < num_vectors; i++)
if (vectors_size > vectors_size + vectors[i].size)
{ {
g_set_error (error, G_IO_ERROR, G_IO_ERROR_INVALID_ARGUMENT, /* No wrap-around for vectors_size */
_("Unable to send message: %s"), if (vectors_size > vectors_size + vectors[i].size)
_("Message vectors too large")); {
return -1; 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; 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 */ /* Check if vector's buffers are too big for gssize */