sf_recv_response_header: call SF_PROTO_CHECK_MAGIC

storage_pool
YuQing 2021-04-12 15:29:01 +08:00
parent 68db56790c
commit ee179a16f7
1 changed files with 11 additions and 1 deletions

View File

@ -56,7 +56,7 @@ int sf_check_response(ConnectionInfo *conn, SFResponseInfo *response,
response->error.message,
"response cmd: %d != expect: %d",
response->header.cmd, expect_cmd);
return EINVAL;
return ERANGE;
}
return 0;
@ -108,6 +108,16 @@ static inline int sf_recv_response_header(ConnectionInfo *conn,
return result;
}
if (!SF_PROTO_CHECK_MAGIC(header_proto.magic)) {
response->error.length = snprintf(response->error.message,
sizeof(response->error.message),
"magic "SF_PROTO_MAGIC_FORMAT" is invalid, "
"expect: "SF_PROTO_MAGIC_FORMAT,
SF_PROTO_MAGIC_PARAMS(header_proto.magic),
SF_PROTO_MAGIC_EXPECT_PARAMS);
return EINVAL;
}
sf_proto_extract_header(&header_proto, &response->header);
return 0;
}