diff --git a/src/ssb.c b/src/ssb.c index 928b1b14..269ab7ae 100644 --- a/src/ssb.c +++ b/src/ssb.c @@ -218,7 +218,7 @@ typedef struct _tf_ssb_connection_t uint8_t s_to_c_box_key[crypto_hash_sha256_BYTES]; uint8_t c_to_s_box_key[crypto_hash_sha256_BYTES]; - uint8_t recv_buffer[8192]; + uint8_t recv_buffer[32 * 1024]; size_t recv_size; uint8_t nonce[crypto_secretbox_NONCEBYTES]; @@ -531,7 +531,7 @@ void tf_ssb_connection_rpc_send(tf_ssb_connection_t* connection, uint8_t flags, memcpy(combined + 1 + 2 * sizeof(uint32_t), message, size); if (connection->ssb->verbose) { - printf(MAGENTA "%s RPC SEND" RESET " flags=%x RN=%d: %.*s\n", connection->name, flags, request_number, (flags & k_ssb_rpc_mask_type) == k_ssb_rpc_flag_binary? 0 : (int)size, message); + printf(MAGENTA "%s RPC SEND" RESET " flags=%x RN=%d: [%zd B] %.*s\n", connection->name, flags, request_number, size, (flags & k_ssb_rpc_mask_type) == k_ssb_rpc_flag_binary ? 0 : (int)size, message); } _tf_ssb_connection_box_stream_send(connection, combined, 1 + 2 * sizeof(uint32_t) + size); tf_free(combined); @@ -1088,6 +1088,12 @@ static void _tf_ssb_connection_verify_client_identity(tf_ssb_connection_t* conne static bool _tf_ssb_connection_recv_pop(tf_ssb_connection_t* connection, uint8_t* buffer, size_t size) { + if (size >= sizeof(connection->recv_buffer)) + { + char message[256]; + snprintf(message, sizeof(message), "Trying to pop a message (%zd) larger than the connection's receive buffer (%zd).", size, sizeof(connection->recv_buffer)); + _tf_ssb_connection_close(connection, message); + } if (connection->recv_size < size) { return false; @@ -1176,6 +1182,7 @@ static void _tf_ssb_connection_rpc_recv(tf_ssb_connection_t* connection, uint8_t { if (_tf_ssb_name_equals(context, val, it->name)) { + printf("called it\n"); it->callback(connection, flags, request_number, val, NULL, 0, it->user_data); found = true; break; diff --git a/src/ssb.rpc.c b/src/ssb.rpc.c index 72556dd9..0b820697 100644 --- a/src/ssb.rpc.c +++ b/src/ssb.rpc.c @@ -45,7 +45,7 @@ static void _tf_ssb_rpc_blobs_get(tf_ssb_connection_t* connection, uint8_t flags const char* id = JS_ToCString(context, arg); uint8_t* blob = NULL; size_t size = 0; - const int k_send_max = 8192; + const int k_send_max = 4096; if (tf_ssb_db_blob_get(ssb, id, &blob, &size)) { for (size_t offset = 0; offset < size; offset += k_send_max) diff --git a/src/ssb.tests.c b/src/ssb.tests.c index 554acd98..a90eca24 100644 --- a/src/ssb.tests.c +++ b/src/ssb.tests.c @@ -625,4 +625,5 @@ void tf_ssb_test_bench(const tf_test_options_t* options) uv_loop_close(&loop); sqlite3_close(db0); + sqlite3_close(db1); }