From patchwork Wed Sep 28 18:40:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 38448 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:3b1c:b0:96:9ee8:5cfd with SMTP id c28csp435126pzh; Wed, 28 Sep 2022 11:41:02 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6ejAcMl/CYnkN66iI97YarierB1oqprAi+gkdl+ddq/gz5X9i5vbDlOmLtjWDWVF6ft06O X-Received: by 2002:a17:906:5d11:b0:787:807e:5b8a with SMTP id g17-20020a1709065d1100b00787807e5b8amr5248641ejt.559.1664390462080; Wed, 28 Sep 2022 11:41:02 -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 i12-20020a50870c000000b0044e8330487esi4856631edb.264.2022.09.28.11.41.01; Wed, 28 Sep 2022 11:41:02 -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="R4a7jId/"; 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 B64C368BBAD; Wed, 28 Sep 2022 21:40:59 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-oln040092073054.outbound.protection.outlook.com [40.92.73.54]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id B822768B844 for ; Wed, 28 Sep 2022 21:40:53 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SPWBw1D3FCDed6rDARmf7MTU2/DTv7fvKWCRxwrAnrWVwt5ziZBaA5sGx6Rt6kXwlGm0c3QWOgrFGH6ZtDrHgGvRy6byzhM/mw1JguNUGDK5NgNyD/vDBqv54qCFDa7DruTGVdCadldBXH/8bbc8bF5ZZz9XlZ3CvjfvAZWBGzM6OU84DBZPyf1By7l1/RHzN+3uiGO74zNnmQKldcHqhO0e7q1+Ry82piOzIWDUDbxvJgry9ODevOFvDaiinQr3fppLQXNojutOw0bqgQbK91MbaT8G9GBtedyj8VFHqT5nYoUdQRNblap4qaoUzbURp3CDCO6LkDGDuJ20p7v0/w== 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=FBc/5ZX4+gtkum2aZjE7zLIOnJvZsuHaLskXrKasY4k=; b=g87WwzFr1NN4e1WsxvtCt2M0wFsaLpZ4Ym8T7fpAA6P0ijAC5uPDaceM16J7h5N/by1FJZH6bsTmiEFaSMtx1zhhqFXUi9hwKoYMnxeWyAeuVRfzOZ1S5z0A1FVf0IYLVgmoJ4ZojNs3S+HFnvdG+SxEYgEvPNVtNiW+93dqs1hZ8iyr8+8nt1crxa+AYv+QV/UH+VgSWjkX+otD4LzVS+mch/W+DJjJlN789P7/lWJEwDLmH7aWJ6cJIhbFC1rEZL8iawUgg/EFLDgiZTAL2kTXkQguCnQc9OGu5W5qVq3pEqFkK/H+VPZm114eTNVMaeaIPhpQdpAKCqDwRJ7inw== 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=FBc/5ZX4+gtkum2aZjE7zLIOnJvZsuHaLskXrKasY4k=; b=R4a7jId/6PUnh8IlHD4wOPFC8DvcPY+eZjlyPWyWemg2LOP8vMZQvV9ZkfQZ8qYmvxbiLEJ3NMBxW+DRM5j7Uq2DRLJPfAoy6Q76NVeJy/MXzDU9Czhnd8ISlbnmVsiwvNeQxiE44l9AEFL6D6BWtt32BuYQaRsJGClbRdAo5LgLQm9qLY/N10DSS7kJIP239264vM2WoxZYP310HkEVP3c+jRro1Zi/kPTxkEEjCW5JYgzc5cjJE/vreLEjLnm6GSb857y078u1RYxRA1vCZ9rXr0EquV1ffsT/6yCmzsZpcKMGhVfxV9+7+VX4IOsDBT0hRDlN7Lxlz2NdJXQ4pQ== Received: from GV1P250MB0737.EURP250.PROD.OUTLOOK.COM (2603:10a6:150:8e::17) by PR3P250MB0132.EURP250.PROD.OUTLOOK.COM (2603:10a6:102:177::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5676.17; Wed, 28 Sep 2022 18:40:52 +0000 Received: from GV1P250MB0737.EURP250.PROD.OUTLOOK.COM ([fe80::68bd:2fc7:ac52:38f8]) by GV1P250MB0737.EURP250.PROD.OUTLOOK.COM ([fe80::68bd:2fc7:ac52:38f8%9]) with mapi id 15.20.5654.025; Wed, 28 Sep 2022 18:40:52 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Wed, 28 Sep 2022 20:40:49 +0200 Message-ID: X-Mailer: git-send-email 2.34.1 X-TMN: [j825ZLdYfzyTWJEpFdMniUgo4YTox7pY] X-ClientProxiedBy: AS9P251CA0018.EURP251.PROD.OUTLOOK.COM (2603:10a6:20b:50f::16) To GV1P250MB0737.EURP250.PROD.OUTLOOK.COM (2603:10a6:150:8e::17) X-Microsoft-Original-Message-ID: <20220928184051.937399-1-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: GV1P250MB0737:EE_|PR3P250MB0132:EE_ X-MS-Office365-Filtering-Correlation-Id: b4a1d817-38c8-4257-f2a0-08daa180f855 X-MS-Exchange-SLBlob-MailProps: ZILSnhm0P3kh+Zs0i80mamVaMOhNuFW0+WpKoCAKNkmOIFnxoyTlo/tpGhURSiiuXcyxchA5F+LzBPSfW3P+V6uDb8aDy1dBIz/eQ56lCVvHt3ZMevdng8vpYg3FOFGkEhPtePkgD2IVCn1dpkKZZzyszotCu3HckMuavjRq7n8LPKt6sty5c0nkmwArjGe6q5zI1YTHEfyWaLFVTsmcZ9QLVvC6lgaKnnPNSvkIsaDXa65ViONgILtyARWDbhRU/667BZf9h0tzgF44ZnRRTzKzyec3GdQR5t9lz87ddzQ/1iTM8FM4AwBrVNQZN75UCUbg//XHGLxtL6gRGIzHZfBunYxefVPbGQLi7C4wFji8i26lvyNMPj9yOVDmxBe14mGi9/R2w9b5aaSlX3RDBUkOwvm1ALc3IGzVbWqKSc8MCejxbPVP3vPLv7kUnN8MC7rK6VljZJTFf45YZ3A6Xu9IJ9d/0bJP96Ja8IbHiEeiXUtOgz19x5aos81uw2mr4K1p/dn3Mv96xMcYFSmL305ystvL6yz0SnIs9CjgZDFEHFTAVGk5vPARxRoRiVVgdLJiecaJ83ZJji6iolzwJpt640Q5qt5K4rutPbNqbP6AHOmz5PheiV9SHul7ANjbvVxT304WUdFI6xBlWmasrMmGtDmg/ftui9u4MMk61yGUoi08Tn3Rv5vrz/kD1RRfptJQNcl/Cn90AodRx8gDIGCpVpJDPAnU0g7skb0cGQChX6jLegIPuGPLhKpwRjBnyomHhc2XsOPTZ33dIYcXTiTZy+gAufMF X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-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0-08daa180f855 X-MS-Exchange-CrossTenant-AuthSource: GV1P250MB0737.EURP250.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Sep 2022 18:40:52.4520 (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: PR3P250MB0132 Subject: [FFmpeg-devel] [PATCH 1/3] avcodec/wmavoice: Don't initialize GetBitContext with buf == NULL 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: mx4t9oY5Entl Happens when flushing. This triggers NULL + 0 (which is UB) in init_get_bits_xe (which previously errored out, but the return value has not been checked) and in copy_bits(). This fixes the wmavoice-(7|11|19)k FATE-tests with UBSan. Signed-off-by: Andreas Rheinhardt --- libavcodec/wmavoice.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/libavcodec/wmavoice.c b/libavcodec/wmavoice.c index 4438089e51..26744719e6 100644 --- a/libavcodec/wmavoice.c +++ b/libavcodec/wmavoice.c @@ -1900,6 +1900,8 @@ static int wmavoice_decode_packet(AVCodecContext *ctx, AVFrame *frame, { WMAVoiceContext *s = ctx->priv_data; GetBitContext *gb = &s->gb; + const uint8_t *buf = avpkt->data; + uint8_t dummy[1]; int size, res, pos; /* Packets are sometimes a multiple of ctx->block_align, with a packet @@ -1908,7 +1910,8 @@ static int wmavoice_decode_packet(AVCodecContext *ctx, AVFrame *frame, * in a single "muxer" packet, so we artificially emulate that by * capping the packet size at ctx->block_align. */ for (size = avpkt->size; size > ctx->block_align; size -= ctx->block_align); - init_get_bits8(&s->gb, avpkt->data, size); + buf = size ? buf : dummy; + init_get_bits8(&s->gb, buf, size); /* size == ctx->block_align is used to indicate whether we are dealing with * a new packet or a packet of which we already read the packet header @@ -1931,7 +1934,7 @@ static int wmavoice_decode_packet(AVCodecContext *ctx, AVFrame *frame, if (cnt + s->spillover_nbits > avpkt->size * 8) { s->spillover_nbits = avpkt->size * 8 - cnt; } - copy_bits(&s->pb, avpkt->data, size, gb, s->spillover_nbits); + copy_bits(&s->pb, buf, size, gb, s->spillover_nbits); flush_put_bits(&s->pb); s->sframe_cache_size += s->spillover_nbits; if ((res = synth_superframe(ctx, frame, got_frame_ptr)) == 0 && @@ -1968,7 +1971,7 @@ static int wmavoice_decode_packet(AVCodecContext *ctx, AVFrame *frame, } else if ((s->sframe_cache_size = pos) > 0) { /* ... cache it for spillover in next packet */ init_put_bits(&s->pb, s->sframe_cache, SFRAME_CACHE_MAXSIZE); - copy_bits(&s->pb, avpkt->data, size, gb, s->sframe_cache_size); + copy_bits(&s->pb, buf, size, gb, s->sframe_cache_size); // FIXME bad - just copy bytes as whole and add use the // skip_bits_next field } From patchwork Wed Sep 28 18:42:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 38450 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:3b1c:b0:96:9ee8:5cfd with SMTP id c28csp436361pzh; Wed, 28 Sep 2022 11:43:13 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4j1DcN88aUneOs2o6749GkLqin45HxGObepZmc+4Ff/zaySkkz0t4bG5EA+mqctvDxvXAb X-Received: by 2002:a17:907:3f9f:b0:782:a14a:fdf9 with SMTP id hr31-20020a1709073f9f00b00782a14afdf9mr23941889ejc.49.1664390593648; Wed, 28 Sep 2022 11:43:13 -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 cy25-20020a0564021c9900b0044efcaeec2asi5250324edb.167.2022.09.28.11.43.13; Wed, 28 Sep 2022 11:43:13 -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=NZKqWQCL; 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 D6B5868BBAD; Wed, 28 Sep 2022 21:43:10 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-oln040092074087.outbound.protection.outlook.com [40.92.74.87]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 5747568B889 for ; Wed, 28 Sep 2022 21:43:04 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZGKLjfaxun0tVbl9KdpD8rAonMxAttSuDY97lBOvvo65BLN8yEa295864KRbJRD5G0CRLCdP64W6/xXMXXMwUZHn22xaRK3QF/G2vrAXFhTMILK7H+421TPSwpWMijrAZaIbwdxNjEwt9alkN3cnendS9JrVhFjvozx3+v2hX1rriqZggR8xvwzUoCF8InJxbzhIysVkNScXz8PsPXzKFhdjAbK8SAHOtXNbPyu4dm1zSFHTjp77lVvQ/uT+N49guzBbIdv6OgJGgW9XlmfPZtSwCutcsMC19XDvvSmYLVvO/lQ2zVtYHRAmeTBXpVYpMwW4QHK+lOd8mN7+OdHX5w== 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=hpX8NQ55a7DJLFNZ/Mw/4DSsQzhezwUGOpCxDsYTIX4=; b=U/QOAQ3xYmsNF480ysyEs2c34jleQtIgwBS7UVuZAt0USABD71ltOVGeDCh4bsSwNO/rn7Lzb2vwb41FRoJYqb0DNbLJwOhFPINFG0RUw7BuHwr2drckm0xoo9qd72EHUvRNkXb2BsGvp3LyvccF39oyVfksv5SYO6k4EVkdSlg+YcWGThJmSNk97+Ksf9KhWtjt/rSTmplKM3YMv/5VQ1AyE2zI1U81VrOHNqzk+a8qcuBBNdCBpBH11r4a3EM3FGCVUSVYfT4HS5Do5dyjoWyTZaVJKXEpTqis3EwJGkJTQhuISIbfpIvPz13a8w3UjSB4UXwD98HcB14yZyKgmg== 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=hpX8NQ55a7DJLFNZ/Mw/4DSsQzhezwUGOpCxDsYTIX4=; b=NZKqWQCL2hVNnrPy32A9bQfRuctscJERHtp333ABP+RYh3wBvf/umtkwl6jsZmBiwJd4mxfmt5vIf852+nh9iAOaWu5dqe64XamnOPkeJev2Gdu9QryHUFqs2zw3AanqdE/7uRKrBg2JgN+46NznAdPD0KC+sfFjXx9NYQH1zJioxwo+6mL0nqx7HgRsAy///4Tp5o5bl9grNx5cD4VAjWWgbDwvlYlimZzwzkxkeP3caA441Q9zNAHwxeo5mIXSsf8FKW4VmvJtt/BwA649/YTHmEndaawNnYNBq/lGlA0vjtCvILc8RV2hrw1bt26ZWPcnlzHLd36g3Ib7EhnDUw== Received: from GV1P250MB0737.EURP250.PROD.OUTLOOK.COM (2603:10a6:150:8e::17) by PR3P250MB0132.EURP250.PROD.OUTLOOK.COM (2603:10a6:102:177::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5676.17; Wed, 28 Sep 2022 18:43:02 +0000 Received: from GV1P250MB0737.EURP250.PROD.OUTLOOK.COM ([fe80::68bd:2fc7:ac52:38f8]) by GV1P250MB0737.EURP250.PROD.OUTLOOK.COM ([fe80::68bd:2fc7:ac52:38f8%9]) with mapi id 15.20.5654.025; Wed, 28 Sep 2022 18:43:02 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Wed, 28 Sep 2022 20:42:59 +0200 Message-ID: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: X-TMN: [rZO6Q9/i+Dtp+tLgl8zUBRrUWAPzdtjpESHaiL7g6vg=] X-ClientProxiedBy: AM6P192CA0099.EURP192.PROD.OUTLOOK.COM (2603:10a6:209:8d::40) To GV1P250MB0737.EURP250.PROD.OUTLOOK.COM (2603:10a6:150:8e::17) X-Microsoft-Original-Message-ID: <20220928184300.937509-1-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: GV1P250MB0737:EE_|PR3P250MB0132:EE_ X-MS-Office365-Filtering-Correlation-Id: 9ec80c3d-7a1f-4f32-c110-08daa18145e0 X-MS-Exchange-SLBlob-MailProps: AZnQBsB9XmpPcoZqFl/i/jhf7c/pX34TVzuF6PMUfbqmGUYupH49yvquJjpx425zJN+JYnI4a9vVUyPIk3OEYKB00iIzAAjSvAGEP62X4uajc9vldLBwTf6IHV5J2tqB7hluYdZiCLhIJ7BgP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+yUVIr4gwnU35RLNJUMAjoNFjJ1Zfd/1JrQw9lVU2k6pETJ5BHY7wW8AyK1A1mvbKOUkKZ4qDiXKw94eFDQNAF4HRpE/QONaeaGjJaoeXLySmaOBXgMjYbuYgrDPcXet4JhVrFGaIH9tLvoyw93zbjcN8WeziVw2R6+i6vXf8Y2skrvZYmvYX65eMzykdFHW5MsswiHJtAr5D+KGC0ByywV1XGwvY+1Fk6d07ZftXCdDkZz/43S6ZckHBsfK/MHvk9agzDiDayDP/hHUDIK2yrfDg/EEaUFuewfsp2RP4P4JVgNA0wvI0iq3rkygSfM8/6zHXZnyInifA0qZjX9+PLuOHqfh+qH2Uvazqa59wlw9F5hTSFHj9/QRkIndLFeHsw9RGTdiXXLT7FgqXD9p4dN7q0Gs+wvZltGarlF0LSnxE/ixuVSkFDgwYPj4y9s5vTBjjRNdZ0A5RvchA7OzeyWa9YXs/0Bca+Cy0+5neaoCoIr7zRxEz3+IvyA6JzZPOh+csf6IPV47WPN6UGs2N6RaYd9LbWbJVzBDecSy8xd9OWS6unVkcd4Ewqt5nwP+uyyB X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9ec80c3d-7a1f-4f32-c110-08daa18145e0 X-MS-Exchange-CrossTenant-AuthSource: GV1P250MB0737.EURP250.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Sep 2022 18:43:02.4382 (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: PR3P250MB0132 Subject: [FFmpeg-devel] [PATCH 2/3] avcodec/wmavoice: Check init_get_bits8() 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: 4rxvy2DpKCMU Signed-off-by: Andreas Rheinhardt --- libavcodec/wmavoice.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libavcodec/wmavoice.c b/libavcodec/wmavoice.c index 26744719e6..bb98f841a5 100644 --- a/libavcodec/wmavoice.c +++ b/libavcodec/wmavoice.c @@ -1911,7 +1911,9 @@ static int wmavoice_decode_packet(AVCodecContext *ctx, AVFrame *frame, * capping the packet size at ctx->block_align. */ for (size = avpkt->size; size > ctx->block_align; size -= ctx->block_align); buf = size ? buf : dummy; - init_get_bits8(&s->gb, buf, size); + res = init_get_bits8(&s->gb, buf, size); + if (res < 0) + return res; /* size == ctx->block_align is used to indicate whether we are dealing with * a new packet or a packet of which we already read the packet header From patchwork Wed Sep 28 18:43:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 38451 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:3b1c:b0:96:9ee8:5cfd with SMTP id c28csp436421pzh; Wed, 28 Sep 2022 11:43:21 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4RIx25sHtmbF+pjIueQaxuxPEYquAIEW65Lml5MDUIdABpyIpo1w+vVb8a3f4lgz/z1bcL X-Received: by 2002:a17:907:a40e:b0:783:4d41:a159 with SMTP id sg14-20020a170907a40e00b007834d41a159mr16138812ejc.212.1664390601536; Wed, 28 Sep 2022 11:43:21 -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 v14-20020a17090606ce00b00778995de77csi4657136ejb.605.2022.09.28.11.43.21; Wed, 28 Sep 2022 11:43:21 -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=meJv4P6k; 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 AA8CA68BBFC; Wed, 28 Sep 2022 21:43:15 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-oln040092074087.outbound.protection.outlook.com [40.92.74.87]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 7F74168BAE5 for ; Wed, 28 Sep 2022 21:43:09 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IvDxc0x+Kr72doECSbfQ3P1YRNGPqPpWWJ/RUYpEK/4SUzMkyIZbHFmj7nRbuBOGrcjDBGVdNRceeT4p5aYkh/Rgoj/S8Polqxh1F0whxyDv5rhgOaw4jEskP+2o3CXrbdFBFhW98CMccgdEKxUGz95wKEfNXoSdoa/3imw05rhYhokzmx34EzWKyZn6HoGQGYRMAGIE8Sahp081SENvqvOBGh8RYHEhh+LFg6NNKqAt83Tox3G8Q96aMOToQejMIS+xxHw+5fLPkvAbjs7YjgMoB8dsIwW2Z5X7KIRFWEwrf2oEyhXaZX5ZrOZoBc4rcjzKE7tt0jF6XpoJWtMTIg== 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=d9fYai2J/9ZZQyO2LFi8mKTVQR9Pcq5+fwt2d22slwY=; b=XgEcc7mUK1vnf0p1UM7oLCPpmh9GUvaXi0qT2GalEBLeTNl0qMpvfqAWVJwkp9NSZWQFLLf/blo5gYVGsvKoudoiThbh/T9LlB9OvArXdhrsHCTnjQO1K2WykavGztR8QMUqlqGkhhprXpbk+SWCZGaBYdajdw2HGZ38CHgAogHRlBdmaD4vHrIMGswGRXfo+J0gIeQ2x21ULbsWeCGUQbIPLngv2J8iG77wfgjwp+VjusA2U/saaE280XfrboCYuT3aSZh2yptVN26yLrkvAj5+/AffMWZH8QTkZi18dCwRlzl6p9yYddTq48NCTH3xk7BM4NFHkdhv4aVl7+0+vg== 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=d9fYai2J/9ZZQyO2LFi8mKTVQR9Pcq5+fwt2d22slwY=; b=meJv4P6kPCIIW4gn07Ra6E0jJi7zKsADZIQ4UFliWzWbxvskU7RCzhgwoYwT8OSOvZFDuJSLRjXcIFwGzapCvePG8FNG96l7CStzu5R12U14kBppFuaeZaaBUVhbXS4H4jK4KRRV63m6gSY/W9kBPXFkAf57qTrY7HbW2/EEiIaSr2kfSWKRkGfHYFRsXxs4JzsCeL3zluuapNnHCJzHnIjQ5YW9qtdnegrIFjahksL6vctiHsUr7Yh/MaOMLRnUzEwm1VKCn0AEzJSKnMF1VOTWjzfkbdqGDgVVGC4579Q19nrOSpCM32GMmNb16dp53/+s0ITZgAwVwu8TScTEmA== Received: from GV1P250MB0737.EURP250.PROD.OUTLOOK.COM (2603:10a6:150:8e::17) by PR3P250MB0132.EURP250.PROD.OUTLOOK.COM (2603:10a6:102:177::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5676.17; Wed, 28 Sep 2022 18:43:04 +0000 Received: from GV1P250MB0737.EURP250.PROD.OUTLOOK.COM ([fe80::68bd:2fc7:ac52:38f8]) by GV1P250MB0737.EURP250.PROD.OUTLOOK.COM ([fe80::68bd:2fc7:ac52:38f8%9]) with mapi id 15.20.5654.025; Wed, 28 Sep 2022 18:43:03 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Wed, 28 Sep 2022 20:43:00 +0200 Message-ID: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: X-TMN: [jZD22S2Gu1Ql7pRqCeyZjGbM2w+zrq3INVImG5tMG/s=] X-ClientProxiedBy: AM6P192CA0099.EURP192.PROD.OUTLOOK.COM (2603:10a6:209:8d::40) To GV1P250MB0737.EURP250.PROD.OUTLOOK.COM (2603:10a6:150:8e::17) X-Microsoft-Original-Message-ID: <20220928184300.937509-2-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: GV1P250MB0737:EE_|PR3P250MB0132:EE_ X-MS-Office365-Filtering-Correlation-Id: c414e70f-680b-493d-89ac-08daa18146d8 X-MS-Exchange-SLBlob-MailProps: AZnQBsB9XmpPcoZqFl/i/jhf7c/pX34TiGRS9/yMDyRqZOza1UCpYM5GnrkwEqAkM+DOJOPahEWLa2ifpiZt+N2zCV6yOKAJf6nxc1HdHcC8kYbKlYTGRwW0n/d8Y/TCKn0A/Q0Codvp4eXnHVnPEDqUHRmW55laE9MmQoG4I2efM4FsMb52w1qDLjYcM/bantpa2gOScKLD+lSrvJUzPqtQaK24qlhLpzy9UdPCmnqKOr7n+PuLXRGCn6IhOIpKwfyWN61oq1bgTGChL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bXib7Dl/2d45PdVOCKxZXxtZgnUuM0oSrAgwwzdSGV1VrAdVLSFB1gn0ZGIVmee4TPoqLXgaxxWcnNagT2hrAje1xfvFIv2O86JvGlgEglb5GDZyv7hTO2Q11WssprJYzjpET713d6ifDNpZkjNslHdDNgzS+/JQfCqKZLJFwpJXp7GAKEmBXM1G97CBKjStiIXNCsrAUvNklR+2uZp+sNedlugAUGc2RaqoD9ZZ6zDzRms4llCJHCQMinsuF+zUO3yJVITYEAQrBZCeVMcWjH+s9pGAWhYwO35eSrwp9/GDV9T+VU48Me1y9ztf4DT3u02GaOWinJKPe6yTlqp3F0TE+eiBjF2sqPciP+m5yTBKiK8lmfFQmmngsRMgL+PgwYxQEwOtsf8rKAVtUeC4YAMBz+XDZ0LM0yt4R3DpKKH/aaqXAs5qzX1kFZqe2T5SgHEr3aRLIEUyrSk8Q1y7TI X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: c414e70f-680b-493d-89ac-08daa18146d8 X-MS-Exchange-CrossTenant-AuthSource: GV1P250MB0737.EURP250.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Sep 2022 18:43:03.9514 (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: PR3P250MB0132 Subject: [FFmpeg-devel] [PATCH 3/3] avcodec/wmalosslessdec: Simplify flushing, avoid NULL + 0 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: qj3Tp7V3br7/ Return immediately if not enough leftover bits are available when flushing. This is simpler and also avoids an init_get_bits(gb, NULL, 0) (which currently leads to NULL + 0, which is UB; this affects the lossless-wma(|-1|-2|-rawtile) FATE tests). Signed-off-by: Andreas Rheinhardt --- libavcodec/wmalosslessdec.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/libavcodec/wmalosslessdec.c b/libavcodec/wmalosslessdec.c index 5112b763fa..d545d848e2 100644 --- a/libavcodec/wmalosslessdec.c +++ b/libavcodec/wmalosslessdec.c @@ -1192,16 +1192,15 @@ static int decode_packet(AVCodecContext *avctx, AVFrame *rframe, s->frame->nb_samples = 0; - if (!buf_size && s->num_saved_bits > get_bits_count(&s->gb)) { + if (!buf_size) { s->packet_done = 0; + if (s->num_saved_bits <= get_bits_count(&s->gb)) + return 0; if (!decode_frame(s)) s->num_saved_bits = 0; } else if (s->packet_done || s->packet_loss) { s->packet_done = 0; - if (!buf_size) - return 0; - s->next_packet_start = buf_size - FFMIN(avctx->block_align, buf_size); buf_size = FFMIN(avctx->block_align, buf_size); s->buf_bit_size = buf_size << 3; @@ -1299,7 +1298,7 @@ static int decode_packet(AVCodecContext *avctx, AVFrame *rframe, s->packet_offset = get_bits_count(gb) & 7; - return (s->packet_loss) ? AVERROR_INVALIDDATA : buf_size ? get_bits_count(gb) >> 3 : 0; + return (s->packet_loss) ? AVERROR_INVALIDDATA : get_bits_count(gb) >> 3; } static void flush(AVCodecContext *avctx)