From patchwork Fri Mar 22 14:41:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 47315 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a21:1743:b0:1a3:ac71:9534 with SMTP id nw3csp181772pzb; Fri, 22 Mar 2024 07:41:59 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVNrl1cSzicqDaB5jlt2oQHMh7OFJaKRdVLeP3znZHI1xKKVORYzFXJcG1VcNTF4StPJ7OI7qIl6Tgb6XST631CsFRV0lL7cZ9goA== X-Google-Smtp-Source: AGHT+IGfT0pmrPyY8cxwGJVpP2eQxfSQrBhOD/IIcnZJeWUv1g2CcLel/sPP7CY/ytDb7SJv94e6 X-Received: by 2002:a17:906:1453:b0:a46:ed72:6bb4 with SMTP id q19-20020a170906145300b00a46ed726bb4mr1787010ejc.72.1711118518967; Fri, 22 Mar 2024 07:41:58 -0700 (PDT) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id p16-20020a1709060e9000b00a3e64ce97fbsi939479ejf.468.2024.03.22.07.41.58; Fri, 22 Mar 2024 07:41:58 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@outlook.com header.s=selector1 header.b=Ar4ZyKVS; arc=fail (body hash mismatch); spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=outlook.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 8AE5968D5AA; Fri, 22 Mar 2024 16:41:54 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-db3eur04olkn2085.outbound.protection.outlook.com [40.92.74.85]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id D4C8268CF01 for ; Fri, 22 Mar 2024 16:41:47 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hauxEWwmkIz2a9Am9acLjDguFNuS76TxtDBuNnE4VzQL6L3JNj5btdEL5BJ5JjaPaLefMJbUlNBYmEaBrX1sBZYow83m0gLkjGS6K/APvbR7Xj/eBzsz8hB4qiuk/1Eq55VWcy4mp4muOyYIw7ucYiK2et8ECF5JOfvex7rL1KDWEFhH63CbFKTkoCyE5hb8bbtdwtgpT+jYHG3IUlLSz3cPrOJ+j5QTIIRaKEcyuqXFjQpHM6JtiSIpNjLTVil5YZBat8C4UQsZYR8f6ZyR8PKSpLJLxN0gHeZ0AzetYkuiSVNJ7m118gCiXTk/7mLcZq1FvRCTlNAYkqlfFFLd3Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=e1Ewv4kDgkJnqnEflbybnSf1Tx4/6PTpZNYsH65RkKE=; b=S8UjHnQh0aHpJljvU7XoLZWtEoMImjB6tNTfMkKFg7Kxv8pf3KUZxi8oHpyfQYz5jMIv7t2If3tc9Shaaec6ftxqG01jXsartGc7VJ1MPf7jFjv8TuTviSn2pBblJbeL7GcPzwBl5/kfXruoyJ0RmQEFLIdK3zlbbrdfeOZ3UY8dr2P4eHXIiaA+35sOTJaJh6xyWp1SSUMYNadyKHE4LxMQF6GmRMUc+vIXd7KDl3Uypa90oBFONPHAqhCxUNqjG0FqtfuuTnLaVXUSpVu/8tGLOGculKrGa+jnPWAn+VKwE83vw1dP9kE/wDbcAnDoB0sVMTtHoxh2XAnViqoc4w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=e1Ewv4kDgkJnqnEflbybnSf1Tx4/6PTpZNYsH65RkKE=; b=Ar4ZyKVS5wB03O6gJyo6b79n72wUD5oXAYAJsXku45zgzg2IhtJxlzfUiu1EJyn85IxtuQz69GJ1SAM7kMDIg/uhRJD1mv56+G0MULFuxHIQqnU3dP9AjObXZI5CL5mTEkY2B5EUSINJFYtx9rjrQ/wKhZd1UXZqB7QHtHM6W/ujk77Z1NQguPwIACOYrB2XWa7hZfHgu06ydkRYVwzh45SpSzifcgDadYFZ5ZKSngj1iswqht5SKnup82BFGzXyNhCAprggA3HW80U2d4JytBsBDkdeuJxIZ+bB0WvHDiX0fgkcZwvWPDIoTnyin5asV+VwGgV9VPhpi9mljDcOLw== Received: from GV1P250MB0737.EURP250.PROD.OUTLOOK.COM (2603:10a6:150:8e::17) by DU2P250MB0238.EURP250.PROD.OUTLOOK.COM (2603:10a6:10:277::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.24; Fri, 22 Mar 2024 14:41:46 +0000 Received: from GV1P250MB0737.EURP250.PROD.OUTLOOK.COM ([fe80::4a3b:cf76:cddc:c68d]) by GV1P250MB0737.EURP250.PROD.OUTLOOK.COM ([fe80::4a3b:cf76:cddc:c68d%4]) with mapi id 15.20.7386.025; Fri, 22 Mar 2024 14:41:46 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Fri, 22 Mar 2024 15:41:38 +0100 Message-ID: X-Mailer: git-send-email 2.40.1 In-Reply-To: References: X-TMN: [RwuyQ1FjITs2nXhsWWmzvvVuznZocP8ExMj0FE+rLBs=] X-ClientProxiedBy: ZR2P278CA0053.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:53::11) To GV1P250MB0737.EURP250.PROD.OUTLOOK.COM (2603:10a6:150:8e::17) X-Microsoft-Original-Message-ID: <20240322144138.199549-1-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: GV1P250MB0737:EE_|DU2P250MB0238:EE_ X-MS-Office365-Filtering-Correlation-Id: 17645a24-bed8-4212-59fb-08dc4a7e32eb X-MS-Exchange-SLBlob-MailProps: Cq7lScuPrnqkjmXb1vlddM5aSa/Epk3AZFAtg5rGR2rBalRY+BGc745mgduPNssppdh5Yfqx9Vd+euVu0+3t0ljWOVrJ3qfCHAwRIAcNfbX2W8mx1035K1qatxdLs7scq9rUZEo6DRssr+kZKG77PJ1gKiOTYilBCCtRWSt8ZerJbBFrnbwce37noRP4EAedeirQtQCPGM/mxTuPws/gs24Th/qEHFPKqiCItOKj9g1Wo96xUZSOXKfowgYsP8q5Oh13x++Nr21aZHfInJtUUFtEyzQyMfrucrA1uQjNYn0RlaKdY/PKk5cOJxo75IAmxPTMb2ZZWqOo6DqLVPXo6kDKRYfq0oXFewqaON4W5dfqXbJvlmSrVfuzOowXI+ZXkQelAvkWhOP5gDie59ez+y01HqbD09ThT+cWNz1lKAN2KJ2lb06Qi9VI3XEsQ1QgbXRtxsA5u6NkgJa6z3F9OJSJFMcD5Rb4dHqAQMaefjRUJxK66QWrDlcaMI5LZgCBzvXiLXyadI/sKNMdMuhBn0uPQFDaKi/Da5jP/QxZY2/0BtmxGcdC87zaJ5XVMt4uiS0FZPbSpBd6jYgoMYgsk3Gzi1Kf0zvVZOiuACXxKTrpWOvx/cdrjKadZueiSqtHwtaJuz5J86ncyDAv5M+AZVagXmPQxU10YfbDLk1JS6mhFdWLNddBWpRu5/SIq5rN2YJANdwzo+MAJbj7zbGs0hHuVVHdlkOf3TDAvf6JT0o3ywUkxW6hsY8Z9s/GnA5Q+3Kt7Adt0Jw= X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: A9OSsZ+cYlcUjGn9qZjE3ZVPXCD1c0llUrkwj6HuWTt0aCXRBCIqk9m7GQz5BKoua+MsUEJXYZaMGUFvDG/H2NedJlyFLaRtMWoCyC7ZAgfjhYW8PBiRp9cv7q5J5D4YKyEiD6Klbs/8BVAcNnngoI8MrClNZ2PbiiVR9fzN2nswshUGDGyhwCujyjYzEKl0HA42u8cs+SuScjB14asvCm0/BV73cmuZ5heENooZhagEuzArw0idJ23dH1pt8unNywZUMkABTrKLEkOcd3M+mk42p/nNh83L29NJw6dNgNeOxRLiPsF6WZ7+yNGQ4ryIBYZe9g9l3JMFFu4e3WDIWOAHdiKjynbfAQnJpymOGsnuu2jCQyWp2+uMQVCTqzu/NX+sYfjpYusjo2xFLOKlBZBrvWQ1v0gDV/7WCPr1m8kjCanSBoyuRjYplr3WOm+2/xcWUcWt1OmxPu9LJhKjKTUOD/Y63nQNn1II5g+A3kBYlv3QoUyT9JQog+SYqRlawT5i7kUU+yzEusn85HCTLZmZaFU0EUSUgQuMBTQO7AMc7e6mBrLzwYfLd5Rpg1jnYxCStgP2U8Ix1ZIikX5pRZ7CBVipojVt2TEkd7PgtrJESKjh9gRvLi/tnZNtLPJH X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: DaI1g7VHqHzh18G072TfY7cqoovt/+rVI1iwY9t9wUhbBNBbiGHPijyqGRiFm7vROu86kDInys3jNQl47jttVIXCTmooz//fHu5j/i5VJ6ASMrkODIYeaLeSFyip3qxrgAqJ/A6iSWH6Hew/2dGNL+IEn427790eTFrx/hWEtD/MH4zBvQs6hLFJ9kTnjj2kkxc+19HgqVzL3WNRulb8FYJkN6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MTlIINYjcvg== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 17645a24-bed8-4212-59fb-08dc4a7e32eb X-MS-Exchange-CrossTenant-AuthSource: GV1P250MB0737.EURP250.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Mar 2024 14:41:46.2989 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU2P250MB0238 Subject: [FFmpeg-devel] [PATCH 5/5] avutil/frame: Use av_realloc_array(), improve overflow check X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Andreas Rheinhardt Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: GE76dfQjXU0o Also use sizeof of the proper type, namely sizeof(**sd) and not sizeof(*sd). Signed-off-by: Andreas Rheinhardt --- libavutil/frame.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libavutil/frame.c b/libavutil/frame.c index 7dd37e5490..d7a32cdc92 100644 --- a/libavutil/frame.c +++ b/libavutil/frame.c @@ -721,10 +721,11 @@ static AVFrameSideData *add_side_data_from_buf(AVFrameSideData ***sd, if (!buf) return NULL; - if (*nb_sd > INT_MAX / sizeof(*sd) - 1) + // *nb_sd + 1 needs to fit into an int and a size_t. + if ((unsigned)*nb_sd >= FFMIN(INT_MAX, SIZE_MAX)) return NULL; - tmp = av_realloc(*sd, (*nb_sd + 1) * sizeof(*sd)); + tmp = av_realloc_array(*sd, sizeof(**sd), *nb_sd + 1); if (!tmp) return NULL; *sd = tmp;