sf_recv_response_header: call SF_PROTO_CHECK_MAGIC
parent
68db56790c
commit
ee179a16f7
|
|
@ -56,7 +56,7 @@ int sf_check_response(ConnectionInfo *conn, SFResponseInfo *response,
|
||||||
response->error.message,
|
response->error.message,
|
||||||
"response cmd: %d != expect: %d",
|
"response cmd: %d != expect: %d",
|
||||||
response->header.cmd, expect_cmd);
|
response->header.cmd, expect_cmd);
|
||||||
return EINVAL;
|
return ERANGE;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -108,6 +108,16 @@ static inline int sf_recv_response_header(ConnectionInfo *conn,
|
||||||
return result;
|
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);
|
sf_proto_extract_header(&header_proto, &response->header);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue