From patchwork Fri Sep 30 17:05:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 38485 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:3b1c:b0:96:9ee8:5cfd with SMTP id c28csp1840060pzh; Fri, 30 Sep 2022 10:06:38 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7qLdD9qlJ/p7Q6HMK6KObkUm3iXSFcAqHnj+pyPztgV/QsTRkbI7Q/zbUjpAYHHVpoh3sw X-Received: by 2002:a17:907:a0c7:b0:787:f13b:5533 with SMTP id hw7-20020a170907a0c700b00787f13b5533mr4247767ejc.50.1664557598477; Fri, 30 Sep 2022 10:06:38 -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 o7-20020a056402038700b00458250c3da7si1102447edv.588.2022.09.30.10.06.14; Fri, 30 Sep 2022 10:06:38 -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=mO3cUIve; 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 8372068BBFB; Fri, 30 Sep 2022 20:06:03 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR03-DBA-obe.outbound.protection.outlook.com (mail-dbaeur03olkn2035.outbound.protection.outlook.com [40.92.58.35]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 42E9E68BBEC for ; Fri, 30 Sep 2022 20:05:57 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eiwRj8V6GvQ1WGmuPJoqKbV2uDGhSuCmlH8GxTIMJdag/MrUhWJvJwCB2l8DpvZirzGT7thV9NkMxb+hbjvECrNPHsT51ht82sepko3LN9KVR5O2R4WuzN01qTZBb7A5pOg6w/16dpfLzZ1I6m5HEE6EMJ1b/kBmCMxrrhHPWqadHSf1EHCW1XIjR1mXQuFEqOJSqwVOMPPfzzyhoQpWykJfVbHhgFPw79xeHANWG16YZZJ/Wjr63VSQSPhkpIapVhYNRSgiKA8MwAHjLtj95Xr5jSKj1US23ERI/b/lZRXw4G2Yp1FwYRvjygY2n7tqMudX74sh+aE2ty7V6e9o0Q== 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=0dbA8Z1CyO/Q7j2K7Wq3yeH3+Ak1iazz4eX1zk9khxU=; b=DxkbDFF+igJBLykPU8qkMhBcq7srEeNCzsI14LmFpUCwR0UQlt916gZ/5wGIssiupkaRgEpyAUrsF2r8OZRkXPGANmf/YMQKW/w5xn4f7Z0A7JTsW2tvN4H6xhG4L7wUeurrmy3f3e0/2MEXRikuMoW9GNXfOBM+sJ9iNeqUDEngWzAVgxv7NrqmtpnZBoiajbHu0642jXLr+MBx8xVifJlzecf9fZXPDzcb7hhxlTQRu9iYFbYP9B2LNpdRo9yUY2j4shVEssw0binvvtukejwVYZg/RKdRlvcR2FhupZyEnci80XGX1yXt5Y3QSn7aKkeDmDrUgl4TFGy8QZvI4A== 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=0dbA8Z1CyO/Q7j2K7Wq3yeH3+Ak1iazz4eX1zk9khxU=; b=mO3cUIve0QNV+4oA3nY+q7S0bU/QTlO2OjukMB0iJd13CTbnWRcX5fSrPh9qwlj1IwLn+Rmz66LTG2zSaMwqDbertaWh7apvg5XjOYvULLQLRoqPZbUnV1Uk71GN+RP9kWmIQtfIZiXs/uLcMEqgK4lrqkPUaIBzoWSK9uAotF9cickOVQUGGUsA6lXItWJ76V4JvHLnlF8bu3F3zANag4GWt91EUlgvW1m6fOi9faLGKf5tgnYD2akV2+mhrTZ6C3ycVBsXI6sTvYtmm7dkUF4jTxWq00hXHFluknALKTJOqOHxZq4RVJu5I8xOXQamA2M3mfrFe2XT4MWDK5ZWFw== Received: from GV1P250MB0737.EURP250.PROD.OUTLOOK.COM (2603:10a6:150:8e::17) by DU2P250MB0175.EURP250.PROD.OUTLOOK.COM (2603:10a6:10:274::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5676.23; Fri, 30 Sep 2022 17:05:47 +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; Fri, 30 Sep 2022 17:05:47 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Fri, 30 Sep 2022 19:05:13 +0200 Message-ID: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: X-TMN: [Cm/uBlAhZxQtEXAv/2Py+DyvDvKa6CXi] X-ClientProxiedBy: FR3P281CA0040.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:4a::8) To GV1P250MB0737.EURP250.PROD.OUTLOOK.COM (2603:10a6:150:8e::17) X-Microsoft-Original-Message-ID: <20220930170515.3648239-4-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: GV1P250MB0737:EE_|DU2P250MB0175:EE_ X-MS-Office365-Filtering-Correlation-Id: 9b0e97f5-e2ae-4a1b-5545-08daa3060427 X-MS-Exchange-SLBlob-MailProps: AZnQBsB9XmrST/aUJU0/QUaXtXS9lKwztdLlpkzskV6QyBdAWfeLkSDgKau/Gcc3gnNv6zg2YXuZyORcxrgU6E3W7tbVHGupbIpvDAH/y/QOUJMvkFWHE4O69zD409+KCMx4kCmXXN4QfZHy9tLilJOCBktA4gMak/51WGvjzk9OSJXCEOOV5ucC5lSSCDNGsoK8LpJbarZL5RHTlrNLmkdw/7TXwL3o/vOripLVVLIY/CNpmrK3UKc8yKEPcWhtOmiZfmcT/iAtuqx9+UjZOdpB9a84yh6xiQM9dNEOnx3MwwsF//PDZyXv89VJQ0OquHLRXtYbeS2aq/WY47vYR1VSCLz8yAjW+15yy4zYc6u01x77+M1WFNb/x9mvTrnYFeWznWBg06p15i2XjMyAAi0h6GhCYQtHBxQZA+h65ZiU6pc5D2p1My068UiD32RpMgzU9lpiXgdHaEDtmL/YjDIsZieASjP3SEEzDsb5p984tRVHtj+iTEVHCZJEjrwiwW4T0+Se/VT688Ynzdlqh+jWwUXf7OMMllTJlZ1w5yHDDLRq/dN+QtmHEE7pAY78Tn7/Fp/3Vq68ELwkcuZCHfNhgsUae4gTVwcfTL08hM6xugPa6ZfvKZ9YtbsNBEE8yfve/RouK63xgSi9AYzyhH6fgALgl8RMhcoGSAD195zWVcSboyKLmWgkZVbOAYBNMnAY0C1ksgfpUPqDkwLNL5nAIqJmUXktGwinq+6/CR91NjKOXLwI4Eg9pH1D8wSeKOgx1O6mor8= X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: U65lwUdJjJRgd/LNx2P7Bo3BFqQtwcglkj53zb00MDGJYWkadSSbdWh/o8/t1mWWh11rPwloCpVFkh332CKVfGlYjwGQrGmowUltPuWqVd4HmxHHLcBVEu9P0W5DxHMduaNBAuABJL222XO3XwilBP+WWUFXOXH41Sh6xoC3keauhW/BxyQmAAHRBrReqnnsnwVE2T02CiHbyfF60XvNgRxudEeK1eYZrBSz9Oe+8Sdng0tFVw8VJtUrux0gY+X3kaXdhAkRUFHMmQPmSPlDQC87T2qRWzDZdJ8aZKHC+ZuhutjEP6r8gIWJh4dv8jbstI8nyu68b+v24plo1s3YJ4eveKnoZOU8dGQsyBVAY5xiFVVzQlca9/C6lMVyFUZE1+5YG6IvlEfMo1fRlO8Z19bZeRpn0h0YTZHFgDZ7Z+8qBOHSQgpcDY5sYjWMlYKw4xQeE6GbABTCIIueYLwQRqQjrM8w3iipR+IwlJFjl1i6zgC3dkaYi6WE9BLIGlyRABaEKafCjfGtzOeRDXyBZDqdySaaw+6yXCnTVUW/xOxkoIUIwjawyCUw1tNhUGXTfiWbEBBTgUyzS0NMbhkbE8ietj5/+tu9gm5Ex9z3TzEoWlggv8T4UgpcrMFkMKFAZBlnApxxja21llaZeoIwMg== X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: dAHKrzWfFQq+HGZcjeoylOqgEcqzy4gUDqmu9RD8ecEn7pyscMur+FuxN3dplKDRIBJyLwcN5uLxY7tDAH30j92CmsFIhPJXAjMdD1fzI+SGAOXVRxNdIteX72EK2rJ2J0FUy1nx7K7Ystn6OErCCLOrMH0bNut1HFG7UZNZetsv3xSnhH6IO0tbrmo9PiycWnd4qeVSRkFLrQ35gYtj91iay0LfIKFKOGmay7xobBSSSfCZbKpXDd7i1oXC7x32PJP3leqgonbzHZh0lVyBKQopRcGigr66clL8OZkPg5Tr8zqoVAZdrlzFe9u5zatd0krfYpoprSkvXYbdWBCv2TeaBE8P0vGr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P250MB0737.EURP250.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Sep 2022 17:05:46.2883 (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: DU2P250MB0175 Subject: [FFmpeg-devel] [PATCH 5/7] avcodec/c93: Fix segfault when using negative linesizes 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: p3TSGprEKaLh c93.c used an int for the stride and an unsigned for the current linenumber. This does not work when using negative linesizes. So use ptrdiff_t for stride and int for linenumber. This fixes the cyberia-c93 FATE test when using negative linesizes. Signed-off-by: Andreas Rheinhardt --- libavcodec/c93.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/libavcodec/c93.c b/libavcodec/c93.c index 66b551a5d6..bfcbc7c150 100644 --- a/libavcodec/c93.c +++ b/libavcodec/c93.c @@ -130,7 +130,8 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *rframe, AVFrame * const oldpic = c93->pictures[c93->currentpic^1]; GetByteContext gb; uint8_t *out; - int stride, ret, i, x, y, b, bt = 0; + int ret, i, x, y, b, bt = 0; + ptrdiff_t stride; if ((ret = ff_set_dimensions(avctx, WIDTH, HEIGHT)) < 0) return ret; @@ -156,7 +157,6 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *rframe, out = newpic->data[0] + y * stride; for (x = 0; x < WIDTH; x += 8) { uint8_t *copy_from = oldpic->data[0]; - unsigned int offset, j; uint8_t cols[4], grps[4]; C93BlockType block_type; @@ -165,16 +165,17 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *rframe, block_type= bt & 0x0F; switch (block_type) { - case C93_8X8_FROM_PREV: - offset = bytestream2_get_le16(&gb); + case C93_8X8_FROM_PREV: { + int offset = bytestream2_get_le16(&gb); if ((ret = copy_block(avctx, out, copy_from, offset, 8, stride)) < 0) return ret; break; + } case C93_4X4_FROM_CURR: copy_from = newpic->data[0]; case C93_4X4_FROM_PREV: - for (j = 0; j < 8; j += 4) { + for (int j = 0; j < 8; j += 4) { for (i = 0; i < 8; i += 4) { int offset = bytestream2_get_le16(&gb); int from_x = offset % WIDTH; @@ -203,7 +204,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *rframe, case C93_4X4_2COLOR: case C93_4X4_4COLOR: case C93_4X4_4COLOR_GRP: - for (j = 0; j < 8; j += 4) { + for (int j = 0; j < 8; j += 4) { for (i = 0; i < 8; i += 4) { if (block_type == C93_4X4_2COLOR) { bytestream2_get_buffer(&gb, cols, 2); @@ -226,7 +227,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *rframe, break; case C93_8X8_INTRA: - for (j = 0; j < 8; j++) + for (int j = 0; j < 8; j++) bytestream2_get_buffer(&gb, out + j*stride, 8); break;