g_return_val_if_fail (stream_id >= 1, -1);
g_return_val_if_fail (component_id >= 1, -1);
g_return_val_if_fail (n_messages == 0 || messages != NULL, -1);
+ g_return_val_if_fail (n_messages <= G_MAXINT, -1);
g_return_val_if_fail (
cancellable == NULL || G_IS_CANCELLABLE (cancellable), -1);
g_return_val_if_fail (error == NULL || *error == NULL, -1);
if (n_messages == 0)
return 0;
+ if (n_messages > G_MAXINT) {
+ g_set_error (error, G_IO_ERROR, G_IO_ERROR_INVALID_ARGUMENT,
+ "The number of messages can't exceed G_MAXINT: %d", G_MAXINT);
+ return -1;
+ }
+
/* Receive buffer size must be at least 1280 for STUN */
if (!agent->reliable) {
for (i = 0; i < n_messages; i++) {
GInputVector local_bufs = { buf, buf_len };
NiceInputMessage local_messages = { &local_bufs, 1, NULL, 0 };
+ if (buf_len > G_MAXSSIZE) {
+ g_set_error (error, G_IO_ERROR, G_IO_ERROR_INVALID_ARGUMENT,
+ "The buffer length can't exceed G_MAXSSIZE: %" G_GSSIZE_FORMAT,
+ G_MAXSSIZE);
+ return -1;
+ }
+
n_valid_messages = nice_agent_recv_messages (agent, stream_id, component_id,
&local_messages, 1, cancellable, error);
GInputVector local_bufs = { buf, buf_len };
NiceInputMessage local_messages = { &local_bufs, 1, NULL, 0 };
+ if (buf_len > G_MAXSSIZE) {
+ g_set_error (error, G_IO_ERROR, G_IO_ERROR_INVALID_ARGUMENT,
+ "The buffer length can't exceed G_MAXSSIZE: %" G_GSSIZE_FORMAT,
+ G_MAXSSIZE);
+ return -1;
+ }
+
n_valid_messages = nice_agent_recv_messages_nonblocking (agent, stream_id,
component_id, &local_messages, 1, cancellable, error);
/* Other error. */
remove_source = TRUE;
break;
- }
+ } /* else if (retval == RECV_OOB) { ignore me and continue; } */
}
}