From cd1920872aacb2f5ce4553a31632880133f5eef1 Mon Sep 17 00:00:00 2001 From: YuQing <384681@qq.com> Date: Sun, 24 Sep 2023 14:31:37 +0800 Subject: [PATCH] sf_recv_response_header check recv length for rdma --- src/sf_proto.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/sf_proto.c b/src/sf_proto.c index a344421..aabf519 100644 --- a/src/sf_proto.c +++ b/src/sf_proto.c @@ -107,6 +107,13 @@ static inline int sf_recv_response_header(ConnectionInfo *conn, if (conn->comm_type == fc_comm_type_rdma) { buffer = G_RDMA_CONNECTION_CALLBACKS.get_buffer(conn); + if (buffer->length < sizeof(SFCommonProtoHeader)) { + response->error.length = sprintf(response->error.message, + "recv pkg length: %d < header size: %d", + buffer->length, (int)sizeof(SFCommonProtoHeader)); + return EINVAL; + } + if ((result=sf_proto_parse_header((SFCommonProtoHeader *) buffer->buff, response)) != 0) {