void-packages/srcpkgs/libArcus/patches/protobuf.patch

43 lines
1.8 KiB
Diff

Migrate away from previously deprecated functions dropped in protobuf>=3.18.0_1.
--- a/src/Socket_p.h
+++ b/src/Socket_p.h
@@ -128,9 +128,6 @@
static const int keep_alive_rate = 500; //Number of milliseconds between sending keepalive packets
- // This value determines when protobuf should warn about very large messages.
- static const int message_size_warning = 400 * 1048576;
-
// This value determines when protobuf should error out because the message is too large.
// Due to the way Protobuf is implemented, messages large than 512MiB will cause issues.
static const int message_size_maximum = 500 * 1048576;
@@ -362,11 +359,15 @@
return;
}
- uint32_t message_size = message->ByteSize();
- if(platform_socket.writeUInt32(message_size) == -1)
+ auto message_size = message->ByteSizeLong();
+ if (message_size > UINT32_MAX) {
+ error(ErrorCode::SendFailedError, "Message size is too large to send");
+ return;
+ }
+
+ if(platform_socket.writeUInt32(static_cast<uint32_t>(message_size)) == -1)
{
error(ErrorCode::SendFailedError, "Could not send message size");
- return;
}
uint32_t type_id = message_types.getMessageTypeId(message);
@@ -548,7 +549,7 @@
google::protobuf::io::ArrayInputStream array(wire_message->data, wire_message->size);
google::protobuf::io::CodedInputStream stream(&array);
- stream.SetTotalBytesLimit(message_size_maximum, message_size_warning);
+ stream.SetTotalBytesLimit(message_size_maximum);
if(!message->ParseFromCodedStream(&stream))
{
error(ErrorCode::ParseFailedError, "Failed to parse message:" + std::string(wire_message->data));