From: Denis Vinogradov Date: Fri, 4 Sep 2020 04:21:33 +0000 (+0900) Subject: use count instead of length for request list X-Git-Tag: MMI-RSA31.Q1-48-36-11~10 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=a2b3df3c923c41488a3a2aa782201ec048576fd6;p=GitHub%2FMotorolaMobilityLLC%2Fexternal-strongswan.git use count instead of length for request list Change-Id: If9cd48244a91a36c38b2f1e4ad88cad37a4962d3 Signed-off-by: Denis Vinogradov --- 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; } } }