From e135ebd2178f8fa2a048eeb5eddd0983d73c6e58 Mon Sep 17 00:00:00 2001 From: lahiker42 Date: Sun, 25 Jan 2009 04:57:32 +0000 Subject: [PATCH] git-svn-id: https://protobuf-c.googlecode.com/svn/trunk@117 00440858-1255-0410-a3e6-75ea37f81c3a --- src/google/protobuf-c/protobuf-c-rpc.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/google/protobuf-c/protobuf-c-rpc.c b/src/google/protobuf-c/protobuf-c-rpc.c index 3d16dd2..58b1361 100644 --- a/src/google/protobuf-c/protobuf-c-rpc.c +++ b/src/google/protobuf-c/protobuf-c-rpc.c @@ -412,6 +412,7 @@ uint32_to_le (uint32_t le) | ((le << 8) & 0xff00); #endif } +#define uint32_from_le uint32_to_le /* make the code more readable, i guess */ static void enqueue_request (ProtobufC_RPC_Client *client, @@ -509,13 +510,26 @@ handle_client_fd_events (int fd, else if (read_rv == 0) { /* handle eof */ - ... + client_failed (client, + "got end-of-file from server [%u bytes incoming, %u bytes outgoing]", + client->incoming.size, client->outgoing.size); } else { /* try processing buffer */ while (client->incoming.size >= 12) { + uint32_t header[3]; + unsigned service_index, message_length, request_id; + protobuf_c_data_buffer_peek (&client->incoming, header, sizeof (header)); + service_index = uint32_from_le (header[0]); + message_length = uint32_from_le (header[1]); + request_id = header[2]; /* already native-endian */ + + if (12 + message_length > client.incoming.size) + break; + + /* lookup request by id */ ... } }