From dc8d7908bbba83df365d146d664713441a8097a3 Mon Sep 17 00:00:00 2001 From: "chufeng.qy@alibaba-inc.com" Date: Fri, 23 Dec 2022 10:50:27 +0800 Subject: [PATCH] check magic --- include/rest_rpc/connection.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/include/rest_rpc/connection.h b/include/rest_rpc/connection.h index 6442507..a9b5abd 100644 --- a/include/rest_rpc/connection.h +++ b/include/rest_rpc/connection.h @@ -155,6 +155,12 @@ private: // const uint32_t body_len = *((int*)(head_)); // req_id_ = *((std::uint64_t*)(head_ + sizeof(int32_t))); rpc_header *header = (rpc_header *)(head_); + if (header->magic != MAGIC_NUM) { + print("protocol error"); + close(); + return; + } + req_id_ = header->req_id; const uint32_t body_len = header->body_len; req_type_ = header->req_type;