summaryrefslogtreecommitdiff
path: root/toxcore/Messenger.c
diff options
context:
space:
mode:
authoriphydf <iphydf@users.noreply.github.com>2018-06-25 12:37:46 +0000
committeriphydf <iphydf@users.noreply.github.com>2018-06-29 23:24:20 +0000
commit706fad1ce88c2104009a3835ee343ff9d8ec8b79 (patch)
treeb2c0d8ccb434515cbbd4e0c9e86ce21f099c11a7 /toxcore/Messenger.c
parent52f21e32518244f3008efbef073f9d3ac9e68b43 (diff)
Add a test to try and overflow the send queue in net_crypto.
Diffstat (limited to 'toxcore/Messenger.c')
-rw-r--r--toxcore/Messenger.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/toxcore/Messenger.c b/toxcore/Messenger.c
index e3ceeb86..7b931bdb 100644
--- a/toxcore/Messenger.c
+++ b/toxcore/Messenger.c
@@ -493,18 +493,22 @@ int m_send_message_generic(Messenger *m, int32_t friendnumber, uint8_t type, con
493 uint32_t *message_id) 493 uint32_t *message_id)
494{ 494{
495 if (type > MESSAGE_ACTION) { 495 if (type > MESSAGE_ACTION) {
496 LOGGER_ERROR(m->log, "Message type %d is invalid", type);
496 return -5; 497 return -5;
497 } 498 }
498 499
499 if (friend_not_valid(m, friendnumber)) { 500 if (friend_not_valid(m, friendnumber)) {
501 LOGGER_ERROR(m->log, "Friend number %d is invalid", friendnumber);
500 return -1; 502 return -1;
501 } 503 }
502 504
503 if (length >= MAX_CRYPTO_DATA_SIZE) { 505 if (length >= MAX_CRYPTO_DATA_SIZE) {
506 LOGGER_ERROR(m->log, "Message length %d is too large", friendnumber);
504 return -2; 507 return -2;
505 } 508 }
506 509
507 if (m->friendlist[friendnumber].status != FRIEND_ONLINE) { 510 if (m->friendlist[friendnumber].status != FRIEND_ONLINE) {
511 LOGGER_ERROR(m->log, "Friend %d is not online", friendnumber);
508 return -3; 512 return -3;
509 } 513 }
510 514
@@ -519,6 +523,8 @@ int m_send_message_generic(Messenger *m, int32_t friendnumber, uint8_t type, con
519 m->friendlist[friendnumber].friendcon_id), packet, length + 1, 0); 523 m->friendlist[friendnumber].friendcon_id), packet, length + 1, 0);
520 524
521 if (packet_num == -1) { 525 if (packet_num == -1) {
526 LOGGER_ERROR(m->log, "Failed to write crypto packet for message of length %d to friend %d",
527 length, friendnumber);
522 return -4; 528 return -4;
523 } 529 }
524 530