From a2b3df3c923c41488a3a2aa782201ec048576fd6 Mon Sep 17 00:00:00 2001 From: Denis Vinogradov Date: Fri, 4 Sep 2020 13:21:33 +0900 Subject: [PATCH] use count instead of length for request list Change-Id: If9cd48244a91a36c38b2f1e4ad88cad37a4962d3 Signed-off-by: Denis Vinogradov --- src/libcharon/comm/vendor_request_list.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/libcharon/comm/vendor_request_list.c b/src/libcharon/comm/vendor_request_list.c index 4aef3f1..0d4c913 100755 --- a/src/libcharon/comm/vendor_request_list.c +++ b/src/libcharon/comm/vendor_request_list.c @@ -63,16 +63,19 @@ vendor_request_list_t* build_vendor_request_list(char *buffer) ); if (buffer != NULL) { - unsigned int size = *((unsigned int*)buffer); - unsigned short *values = (unsigned short*)(buffer + sizeof(int)); + typedef struct { + unsigned int count; + unsigned short values[0]; + } packed_ushort_list_t; - if (size) + packed_ushort_list_t *request = (packed_ushort_list_t*)buffer; + if (request->count) { - this->size = size / 2; + this->size = request->count; this->values = calloc(this->size, sizeof(unsigned int)); for (int i = 0; i < this->size; i++) { - this->values[i] = values[i] & 0xFFFF; + this->values[i] = request->values[i] & 0xFFFF; } } } -- 2.20.1