mirror of
https://github.com/protobuf-c/protobuf-c.git
synced 2024-12-28 14:48:18 +08:00
protobuf-c-rpc/protobuf-c-rpc.c: perform a more thorough message
check for server closures (responses) to not crash the server in case of a malformed message (related to #76)
This commit is contained in:
parent
fb39c17616
commit
b1056e922a
@ -1054,7 +1054,7 @@ server_connection_response_closure (const ProtobufCMessage *message,
|
|||||||
|
|
||||||
uint8_t buffer_slab[512];
|
uint8_t buffer_slab[512];
|
||||||
ProtobufCBufferSimple buffer_simple = PROTOBUF_C_BUFFER_SIMPLE_INIT (buffer_slab);
|
ProtobufCBufferSimple buffer_simple = PROTOBUF_C_BUFFER_SIMPLE_INIT (buffer_slab);
|
||||||
if (message == NULL)
|
if (!protobuf_c_message_check (message))
|
||||||
{
|
{
|
||||||
/* send failed status */
|
/* send failed status */
|
||||||
uint32_t header[4];
|
uint32_t header[4];
|
||||||
@ -1064,6 +1064,8 @@ server_connection_response_closure (const ProtobufCMessage *message,
|
|||||||
header[3] = request->request_id;
|
header[3] = request->request_id;
|
||||||
protobuf_c_buffer_simple_append (&buffer_simple.base,
|
protobuf_c_buffer_simple_append (&buffer_simple.base,
|
||||||
16, (uint8_t *) header);
|
16, (uint8_t *) header);
|
||||||
|
server_failed_literal (server, PROTOBUF_C_ERROR_CODE_BAD_REQUEST,
|
||||||
|
"response message was malformed, sending failed status to client");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user