From 40ff7bf1c119553707a266980a7abba9bf0a414f Mon Sep 17 00:00:00 2001 From: Archie Pusaka Date: Thu, 17 Jun 2021 08:53:34 +0800 Subject: [PATCH] avdtp: Fix parsing capabilities This patch fixes size comparison and variable misassignment. Reviewed-by: Alain Michaud Reviewed-by: Michael Sun Signed-off-by: Anuj Jain Signed-off-by: Ayush Garg --- profiles/audio/avdtp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/profiles/audio/avdtp.c b/profiles/audio/avdtp.c index d1f8440..a614df7 100644 --- a/profiles/audio/avdtp.c +++ b/profiles/audio/avdtp.c @@ -1766,7 +1766,7 @@ static GSList *caps_to_list(uint8_t *data, size_t size, cap = (struct avdtp_service_capability *)data; - if (sizeof(*cap) + cap->length >= size) { + if (sizeof(*cap) + cap->length > size) { error("Invalid capability data in getcap resp"); break; } @@ -1788,7 +1788,7 @@ static GSList *caps_to_list(uint8_t *data, size_t size, switch (cap->category) { case AVDTP_MEDIA_CODEC: if (codec) - *codec = cap; + *codec = cpy; break; case AVDTP_DELAY_REPORTING: if (delay_reporting) -- 2.7.4