From patchwork Thu Oct 27 16:36:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Martin Vallevand X-Patchwork-Id: 619361 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 60688FA3740 for ; Thu, 27 Oct 2022 16:36:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233978AbiJ0Qgm (ORCPT ); Thu, 27 Oct 2022 12:36:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53432 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235993AbiJ0Qgk (ORCPT ); Thu, 27 Oct 2022 12:36:40 -0400 Received: from sonic312-27.consmr.mail.gq1.yahoo.com (sonic312-27.consmr.mail.gq1.yahoo.com [98.137.69.208]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 771D8172B57 for ; Thu, 27 Oct 2022 09:36:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rogers.com; s=s2048; t=1666888598; bh=OfE/B8edksCQjG+dQ4GbWcUcsrRUOsy47oBArYnuIMM=; h=Date:To:From:Subject:References:From:Subject:Reply-To; b=QrN5mAUr4RF6R7p+4198TRCidItnaQR+XoAntLhKCVWXeJxX5FwIQg0WgJLUw+ra1q2DR747AjobrpGU0kPviacq3hPontpUTxYEfC7pQk4eKR7WVHFZ8bgmHi6Il4MZ/ZFnwYVjIkLI6IM08Z7I8GmidbzfE/9afmNksNSohczb4ydiQc3NwoUQMn2tLON3IEOFCBAljbhhPbs1Qba5ECT9W4jUsjGbe4KgYTur/MgT5ZsGeIo/g44E5SkhAqoW92qvpnh+MA3lSnoY4SU70k0HklTjPhBzXIFOxgc23rRJ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aU4S76gxwAzw_OhwwVopcTkpxEHkVU2LAQclBPwHP5hnKhxzwcrtVrqvaxhnUd_ logGxhs3zgoCnDBSU6_ImarqqM0BDQJ_ukYu_EL1VYLxzxseiES0jKfx9i468BBvcq6tPGjg7eCL nnJjQukmIF9pnf49gECYfs.zrlul6yer.Bk8PC4DRFk8VKSWQuAIA7InyeOR_ubPxONRJuUuA.J6 Z8kHOZdbX.VsLatW1Ro0Yi9ikiJc4pCmagJTLS6KYoJLaX4lHloV9hPYbtZqFpuPLSKX9wPRUb9Y 6F6jI8qeDle9EyYI7C.jpsqWfL3cwExoh0QFdna2.gcCXpfpKCUMiQfdlz3Kex8rk.fEZSTNmzic YNF8rUTlUS6.8OhlxR0dODmyUWiYP.XV5z6kHmDNN8IK5sUsIrF0PAXn2gl11JdKETMYC5CobXeI NcSnux2LMZRhG4ywAX6gf38xSVHeVHV_MDkd1h1K0xNAPmdn6_jDX_Oh2jPJVMEzJCW.Ro3rqZrG Q5YZUb5K7kzmD5fdSg8lSuAL52.UyT1aZSiEAbhVfOX5tcz8ltK3ENpWSb8bprr9uslbePgdUE4S lRVeCeTVhWuCzy6c9X_fKrCJvLjulL5Mg3niBtmaIu_pN2vyLye5Y6YdCheJtCC.aEpDesCNMV5m xhHatxEfsAVcg X-Sonic-MF: Received: from sonic.gate.mail.ne1.yahoo.com by sonic312.consmr.mail.gq1.yahoo.com with HTTP; Thu, 27 Oct 2022 16:36:38 +0000 Received: by hermes--production-gq1-754cb59848-xxkcq (Yahoo Inc. Hermes SMTP Server) with ESMTPA ID 54aca23f85577752393125f92734d7b5; Thu, 27 Oct 2022 16:36:35 +0000 (UTC) Message-ID: <61b25413-d877-3a8f-344b-651e4b7885a2@rogers.com> Date: Thu, 27 Oct 2022 12:36:33 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.4.0 Content-Language: en-US To: linux-media@vger.kernel.org From: Martin Vallevand Subject: [PATCH] libdvbv5: cleanup ASTC service location parsing References: <61b25413-d877-3a8f-344b-651e4b7885a2.ref@rogers.com> X-Mailer: WebService/1.1.20783 mail.backend.jedi.jws.acl:role.jedi.acl.token.atz.jws.hermes.yahoo Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org >From 0e0aba1f610e7355a9783dfad82dcdacb69ceae4 Mon Sep 17 00:00:00 2001 From: Martin Vallevand Date: Thu, 27 Oct 2022 08:45:15 -0400 Subject: [PATCH] libdvbv5: cleanup ASTC service location parsing Logic attempted  to move raw data from the generic DVB descriptor into a linked list with a different structure. Calculation for the destination length would always fail as a result.  Commit  moves specific data elements ---  .../descriptors/desc_atsc_service_location.c    | 17 +++++++++++------  1 file changed, 11 insertions(+), 6 deletions(-)          return -1;      }      if (dlen > len) { -- 2.25.1 diff --git a/lib/libdvbv5/descriptors/desc_atsc_service_location.c b/lib/libdvbv5/descriptors/desc_atsc_service_location.c index 8b423dc5..ef88facb 100644 --- a/lib/libdvbv5/descriptors/desc_atsc_service_location.c +++ b/lib/libdvbv5/descriptors/desc_atsc_service_location.c @@ -34,21 +34,26 @@ int atsc_desc_service_location_init(struct dvb_v5_fe_parms *parms,      int i;      size_t len, dlen = desc->length; -    len = sizeof(*s_loc); +    // raw data should have one element +    len = sizeof(u_int16_t) + sizeof(u_int8_t) + sizeof(struct atsc_desc_service_location_elementary); +      if (dlen < len) {          dvb_logwarn("ATSC service location descriptor is too small");          return -1;      } -    memcpy(s_loc, p, len); -    p += len; -    dlen -= len; - +    memcpy(&s_loc->bitfield , p, sizeof(u_int16_t)); +    p += sizeof(u_int16_t); +    dlen -= sizeof(u_int16_t);      bswap16(s_loc->bitfield); +    memcpy(&s_loc->number_elements , p, sizeof(u_int8_t)); +    p += sizeof(u_int8_t); +    dlen -= sizeof(u_int8_t); +      len = s_loc->number_elements * sizeof(*s_loc->elementary);      if (dlen < len) { -        dvb_logwarn("ATSC service location descriptor is too small"); +        dvb_logwarn("ATSC service location descriptor is too small for %d elements", s_loc->number_elements);