summaryrefslogtreecommitdiff
path: root/toxav/msi.c
diff options
context:
space:
mode:
authormannol <eniz_vukovic@hotmail.com>2015-04-21 02:31:12 +0200
committermannol <eniz_vukovic@hotmail.com>2015-04-21 02:31:12 +0200
commit3fd0ee5f0873924b4881b0e33eb1c17ea877ab4a (patch)
tree6a4ee64a3ea7f0191ccfd0205a68411cf0b84063 /toxav/msi.c
parentcbb8fdd4eab3bae4db1179f1fa04cdaa35957aeb (diff)
Final touchups
Diffstat (limited to 'toxav/msi.c')
-rw-r--r--toxav/msi.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/toxav/msi.c b/toxav/msi.c
index c313e288..b7926e07 100644
--- a/toxav/msi.c
+++ b/toxav/msi.c
@@ -188,7 +188,7 @@ int msi_invite ( MSISession *session, MSICall **call, uint32_t friend_id, uint8_
188 msg.capabilities.value = capabilities; 188 msg.capabilities.value = capabilities;
189 189
190 msg.vfpsz.exists = true; 190 msg.vfpsz.exists = true;
191 msg.vfpsz.value = htons(VIDEOFRAME_PIECE_SIZE); 191 msg.vfpsz.value = VIDEOFRAME_PIECE_SIZE;
192 192
193 send_message ( (*call)->session->messenger, (*call)->friend_id, &msg ); 193 send_message ( (*call)->session->messenger, (*call)->friend_id, &msg );
194 194
@@ -238,7 +238,7 @@ int msi_answer ( MSICall* call, uint8_t capabilities )
238 msg.capabilities.value = capabilities; 238 msg.capabilities.value = capabilities;
239 239
240 msg.vfpsz.exists = true; 240 msg.vfpsz.exists = true;
241 msg.vfpsz.value = htons(VIDEOFRAME_PIECE_SIZE); 241 msg.vfpsz.value = VIDEOFRAME_PIECE_SIZE;
242 242
243 send_message ( session->messenger, call->friend_id, &msg ); 243 send_message ( session->messenger, call->friend_id, &msg );
244 244
@@ -349,6 +349,12 @@ int msg_parse_in ( MSIMessage *dest, const uint8_t *data, uint16_t length )
349 case IDVFPSZ: 349 case IDVFPSZ:
350 CHECK_SIZE(it, size_constraint, 2); 350 CHECK_SIZE(it, size_constraint, 2);
351 SET_UINT16(it, dest->vfpsz); 351 SET_UINT16(it, dest->vfpsz);
352 dest->vfpsz = ntohs(dest->vfpsz);
353
354 if (dest->vfpsz.value > 1200) {
355 LOGGER_ERROR("Invalid vfpsz param");
356 return -1;
357 }
352 break; 358 break;
353 359
354 default: 360 default:
@@ -419,8 +425,9 @@ int send_message ( Messenger* m, uint32_t friend_id, const MSIMessage *msg )
419 } 425 }
420 426
421 if (msg->vfpsz.exists) { 427 if (msg->vfpsz.exists) {
422 it = msg_parse_header_out(IDVFPSZ, it, &msg->vfpsz.value, 428 uint16_t nb_vfpsz = htons(msg->vfpsz);
423 sizeof(msg->vfpsz.value), &size); 429 it = msg_parse_header_out(IDVFPSZ, it, &nb_vfpsz,
430 sizeof(nb_vfpsz), &size);
424 } 431 }
425 432
426 if ( it == parsed ) { 433 if ( it == parsed ) {
@@ -620,7 +627,7 @@ void handle_push ( MSICall *call, const MSIMessage *msg )
620 goto FAILURE; 627 goto FAILURE;
621 } 628 }
622 629
623 call->peer_vfpsz = ntohs(msg->vfpsz.value); 630 call->peer_vfpsz = msg->vfpsz.value;
624 } 631 }
625 632
626 633
@@ -645,7 +652,7 @@ void handle_push ( MSICall *call, const MSIMessage *msg )
645 * is not terminated on our side. We can assume that 652 * is not terminated on our side. We can assume that
646 * in this case we can automatically answer the re-call. 653 * in this case we can automatically answer the re-call.
647 */ 654 */
648 if (call->peer_vfpsz != ntohs(msg->vfpsz.value)) { 655 if (call->peer_vfpsz != msg->vfpsz.value) {
649 LOGGER_WARNING("Friend sent invalid parameters for re-call"); 656 LOGGER_WARNING("Friend sent invalid parameters for re-call");
650 call->error = msi_EInvalidParam; 657 call->error = msi_EInvalidParam;
651 invoke_callback(call, msi_OnError); 658 invoke_callback(call, msi_OnError);
@@ -661,7 +668,7 @@ void handle_push ( MSICall *call, const MSIMessage *msg )
661 msg.capabilities.value = call->self_capabilities; 668 msg.capabilities.value = call->self_capabilities;
662 669
663 msg.vfpsz.exists = true; 670 msg.vfpsz.exists = true;
664 msg.vfpsz.value = htons(VIDEOFRAME_PIECE_SIZE); 671 msg.vfpsz.value = VIDEOFRAME_PIECE_SIZE;
665 672
666 send_message ( call->session->messenger, call->friend_id, &msg ); 673 send_message ( call->session->messenger, call->friend_id, &msg );
667 674