From b1056e922a01fce8790ba56aca4f1caa6e3a1f1d Mon Sep 17 00:00:00 2001 From: Ilya Lipnitskiy Date: Wed, 27 Nov 2013 15:21:40 -0800 Subject: [PATCH] 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) --- protobuf-c-rpc/protobuf-c-rpc.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/protobuf-c-rpc/protobuf-c-rpc.c b/protobuf-c-rpc/protobuf-c-rpc.c index 113809c..0cca82a 100644 --- a/protobuf-c-rpc/protobuf-c-rpc.c +++ b/protobuf-c-rpc/protobuf-c-rpc.c @@ -1054,7 +1054,7 @@ server_connection_response_closure (const ProtobufCMessage *message, uint8_t buffer_slab[512]; ProtobufCBufferSimple buffer_simple = PROTOBUF_C_BUFFER_SIMPLE_INIT (buffer_slab); - if (message == NULL) + if (!protobuf_c_message_check (message)) { /* send failed status */ uint32_t header[4]; @@ -1064,6 +1064,8 @@ server_connection_response_closure (const ProtobufCMessage *message, header[3] = request->request_id; protobuf_c_buffer_simple_append (&buffer_simple.base, 16, (uint8_t *) header); + server_failed_literal (server, PROTOBUF_C_ERROR_CODE_BAD_REQUEST, + "response message was malformed, sending failed status to client"); } else {