From 4062025312eaf960709d37e8b436537253423809 Mon Sep 17 00:00:00 2001 From: Vijay Pai Date: Wed, 18 Dec 2019 22:20:31 -0800 Subject: [PATCH] Check for negative on NextMessageSize --- include/grpcpp/impl/codegen/sync_stream_impl.h | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/include/grpcpp/impl/codegen/sync_stream_impl.h b/include/grpcpp/impl/codegen/sync_stream_impl.h index a69f4503e7e..80b0bd73d2a 100644 --- a/include/grpcpp/impl/codegen/sync_stream_impl.h +++ b/include/grpcpp/impl/codegen/sync_stream_impl.h @@ -193,7 +193,8 @@ class ClientReader final : public ClientReaderInterface { } bool NextMessageSize(uint32_t* sz) override { - *sz = call_.max_receive_message_size(); + int result = call_.max_receive_message_size(); + *sz = (result > 0) ? result : UINT32_MAX; return true; } @@ -463,7 +464,8 @@ class ClientReaderWriter final : public ClientReaderWriterInterface { } bool NextMessageSize(uint32_t* sz) override { - *sz = call_.max_receive_message_size(); + int result = call_.max_receive_message_size(); + *sz = (result > 0) ? result : UINT32_MAX; return true; } @@ -597,7 +599,8 @@ class ServerReader final : public ServerReaderInterface { } bool NextMessageSize(uint32_t* sz) override { - *sz = call_->max_receive_message_size(); + int result = call_->max_receive_message_size(); + *sz = (result > 0) ? result : UINT32_MAX; return true; } @@ -724,7 +727,8 @@ class ServerReaderWriterBody final { } bool NextMessageSize(uint32_t* sz) { - *sz = call_->max_receive_message_size(); + int result = call_->max_receive_message_size(); + *sz = (result > 0) ? result : UINT32_MAX; return true; }