修复cmsg解析问题
This commit is contained in:
@@ -65,11 +65,15 @@ int kni_cmsg_set(struct kni_cmsg *cmsg, uint16_t type, const unsigned char *valu
|
||||
int kni_cmsg_get(struct kni_cmsg *cmsg, uint16_t type, uint16_t *size, unsigned char **pvalue)
|
||||
{
|
||||
struct kni_cmsg_tlv *tlv = NULL;
|
||||
if(type >= KNI_CMSG_TLV_NR_MAX || (tlv = cmsg->tlvs[type]) == NULL)
|
||||
if(type >= KNI_CMSG_TLV_NR_MAX)
|
||||
{
|
||||
*size = 0;
|
||||
return KNI_CMSG_INVALID_TYPE;
|
||||
}
|
||||
if((tlv = cmsg->tlvs[type]) == NULL){
|
||||
*size = 0;
|
||||
return KNI_CMSG_TYPE_UNSET;
|
||||
}
|
||||
*size = tlv->length - sizeof(struct kni_cmsg_tlv);
|
||||
*pvalue = tlv->value_as_string;
|
||||
return 0;
|
||||
@@ -153,6 +157,7 @@ int kni_cmsg_deserialize(const unsigned char *data, uint16_t len, struct kni_cms
|
||||
cmsg = ALLOC(struct kni_cmsg, 1);
|
||||
offset = sizeof(struct kni_cmsg_serialize_header);
|
||||
nr_tlvs = ntohs(header->nr_tlvs);
|
||||
printf("nr_tlvs is %d\n", nr_tlvs);
|
||||
for(int i = 0; i < nr_tlvs; i++)
|
||||
{
|
||||
struct kni_cmsg_tlv *tlv = (struct kni_cmsg_tlv*)(data + offset);
|
||||
@@ -161,6 +166,7 @@ int kni_cmsg_deserialize(const unsigned char *data, uint16_t len, struct kni_cms
|
||||
goto error_out;
|
||||
}
|
||||
uint16_t type = ntohs(tlv->type);
|
||||
printf("type = %d\n", type);
|
||||
uint16_t length = ntohs(tlv->length);
|
||||
if(length < sizeof(struct kni_cmsg_tlv) || offset + length > len)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user