From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 7F9794306D for ; Thu, 13 Jan 2022 14:38:31 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id CD88468B7D9; Thu, 13 Jan 2022 16:38:29 +0200 (EET) Received: from EUR03-AM5-obe.outbound.protection.outlook.com (mail-oln040092070039.outbound.protection.outlook.com [40.92.70.39]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 33A3C68B784 for ; Thu, 13 Jan 2022 16:38:23 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FuuOXN46FY7jYfzT97U/3GCqbFsym3V24bKIqm0HK2jwOC2QFhUas7L/WNbGsshKA35d2/jazZI0+XyfpgTSO+ttgkj9sodGfow+7//acoRbk9lt2CFa+FN89Fl49YQpRAY1roSdcYvbX+wZ5CaefKFwd2F9Rey3Krj+EhX6ofdxEdZBa5l7FxtF4qzRmKo6kxElepGk/XQwEBiPBsKi2oJLmzM8w2TwGUebgIgiacM1GQ+2M4NUMB3eDHLFKyPO+9ZZyKxGenjiwK4KBX8tGIWoGKrtWqqM6KdNf3b1muS/fvKCd6czUrmygTmJRALr995VhSYAtOV1E1NrxTjsSg== 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=ATS5aFG3+r+lM4jiusz384i9VTlhsWRvZ/4/XxV7n3Y=; b=gThNXOEhPrRxh1yyg7BTBp9hVEmcATJ6Fgq6ObkwqcUil/yX2qJFxPhL8KBupzl9rs9smubO5jWoxfycyUU67IkjFExVQb/ZlGGCZZ7VaqrJI/bb3TgrFnXe+GDEyGC3ru93zQQDlY56rpvcPy6G6jR6/FOGMnLuYvR6o24KYW/Kwf3lwlg/vX/T+wNbOFjTGBrF6sT2I5JXbbScw4QNMhU9mXACeawJHU2iJ90MEQCYRGE3msg6w7oIol+FsXgIKZK3G6L/jDgpEgSuXAraIaxFzMweCx3e2VPiCkI/9tXC6o+lg4jcXsVlz3VQamb/fMpVWHnl11mv39ENu9awHg== 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=ATS5aFG3+r+lM4jiusz384i9VTlhsWRvZ/4/XxV7n3Y=; b=XcKl9soohCxOCheaRu/Z/GON4ikXlpgdlxQqp+wItk1aWm6x2ipcbbglvjaDt0STj9UxUVAEDIdpU6EUANkSSOLffEZDai5Vn0d7Fj2fRZBV93qyop8PBqgYtRZ0K9EwFiSz8CwG4okS0mAxTFFyC0PJVEWEOrSUzq3AEgCUU95+s7lU15ruBk+BmRbHu7JNLdm68gqcA5EgBUrZOkxa3ObNi+AXBBm+s9RrkXWMhj5w6+S2yQ/jioJDU6+P2LfQFvY7gVAi6eT4bFXdVVOqFMGiMQfhfb/kqAFdXXam2UUZz3ovIfs2ojvQ+HYNFQRDjuWEz0cfGdmHgNsqFOqimg== Received: from AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) by AM6PR0302MB3415.eurprd03.prod.outlook.com (2603:10a6:209:1e::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4888.9; Thu, 13 Jan 2022 14:38:20 +0000 Received: from AM7PR03MB6660.eurprd03.prod.outlook.com ([fe80::19fc:be9f:2c9c:53f5]) by AM7PR03MB6660.eurprd03.prod.outlook.com ([fe80::19fc:be9f:2c9c:53f5%9]) with mapi id 15.20.4888.010; Thu, 13 Jan 2022 14:38:20 +0000 Message-ID: Date: Thu, 13 Jan 2022 15:38:19 +0100 Content-Language: en-US To: ffmpeg-devel@ffmpeg.org References: <20220111204610.14262-1-anton@khirnov.net> <164208402130.23111.5697543505397164851@lain.red.khirnov.net> From: Andreas Rheinhardt In-Reply-To: <164208402130.23111.5697543505397164851@lain.red.khirnov.net> X-TMN: [rlPjH/shz68nPsfPCnEmpbCtZsH31kr3] X-ClientProxiedBy: AS9PR04CA0044.eurprd04.prod.outlook.com (2603:10a6:20b:46a::22) To AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) X-Microsoft-Original-Message-ID: <89a05278-dab4-7094-ea89-827dd4d1c565@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 621c0fb8-5ebf-4f8b-e1aa-08d9d6a2583b X-MS-TrafficTypeDiagnostic: AM6PR0302MB3415:EE_ X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: /8ao3c57/dHWiGu7yitLvfDr2bHn/49DrbitRnDO6Uk+ufZOLF6XPqJ7ZhnVo0h9XXOSVAIMAZedGwrpqpb4BdHArLbc5p/GJq5yj+SLnj5sCftphzCpE8U2Dyi9IXNYoo3NswFI9+r+EdqP2TZkWg78O9xU1tjC6Jzsfynoz254lSbE9NVxieJgJQ2cNAZZs5194DdNXBBzOajJ/0NMQkZNN1vxOrzSExjebvaZFP9PgEekPltC/thx3XJp/+Mt9D8gWialBln+9asm1iOdxkHk2qWStRLrvlRmcFuIG4t4V4LuFB4IyVIbZKtGFxfKvH0qnPsPr8xrOUQynV5Y0FJq9p8t7YHSfLcM5/3iMV9HpsL32EZDYhvF5ejeZi1/x4CfWzvNXA0x0Z7TC3D9eE3otnTwbQpNFFhyTUI+cGP62jGxcYMEA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psY290UExiZ0E0cUVw?= =?utf-8?B?L2ozWEM4NzQxTUZrWHExY09XV3NvZS9ZSkRpRWlSczFtU1JrU01JaFZzMS9k?= =?utf-8?B?STFtd09STFVLQkNMcmEwWUxwRG1RQVM4SEdpcEo2ZERRRTRFRStWWUg4aFhw?= =?utf-8?B?alFNMi9qSHBTU2h4ZmlJeVpxVlQ0am5WaXpWZ3BWSHJrdmlxM250TkdLUC9S?= =?utf-8?B?M2ZYeU91QTNDSXYwTGpEZ3lLVVhKdEhiSDZIZHlDR1FYQ0lPZGtqRFFvK0pF?= =?utf-8?B?MEtpL1piRWxtZnNwSDNycUdyZ2ZQUXAzbTJSNWN6VkN2U2hYNklla3M2SmZD?= =?utf-8?B?eG9za3k0K3VDc2o3UFVmRitZWjh4MEs3WStwdGhnZlJqV0VhNzB5emhBbHdN?= =?utf-8?B?WUttVC91MjJYVkJTZnlQYVB5MGlNaWp5NFVNazNRckdQczdYTElCRDJFa2NY?= =?utf-8?B?YWd5MXdLU1drZkJLOUN3STY4OTRpWm5EaGxqRWIzM0pHcnowbkFsODgvdk04?= =?utf-8?B?bmIvYlVGNDF1bVh3cTIyL0ZldWp0a0txM3Jab3M4d1NoUzVNU1ZTckVvY3Jv?= =?utf-8?B?TFhoS2FiZGhjTDBpMTgxdUIvS1lRV0htWktnN0pMNmYycWRLdz09?= X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 621c0fb8-5ebf-4f8b-e1aa-08d9d6a2583b X-MS-Exchange-CrossTenant-AuthSource: AM7PR03MB6660.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Jan 2022 14:38:20.5657 (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: AM6PR0302MB3415 Subject: Re: [FFmpeg-devel] [PATCH 01/35] lavu/fifo: disallow overly large fifo sizes 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 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: Anton Khirnov: > Quoting Andreas Rheinhardt (2022-01-13 14:59:49) >> Anton Khirnov: >>> The API currently allows creating FIFOs up to >>> - UINT_MAX: av_fifo_alloc(), av_fifo_realloc(), av_fifo_grow() >>> - SIZE_MAX: av_fifo_alloc_array() >>> However the usable limit is determined by >>> - rndx/wndx being uint32_t >>> - av_fifo_[size,space] returning int >>> so no FIFO should be larger than the smallest of >>> - INT_MAX >>> - UINT32_MAX >>> - SIZE_MAX >>> (which should be INT_MAX an all commonly used platforms). >>> Return an error on trying to allocate FIFOs larger than this limit. >>> --- >>> libavutil/fifo.c | 14 +++++++++++++- >>> 1 file changed, 13 insertions(+), 1 deletion(-) >>> >>> diff --git a/libavutil/fifo.c b/libavutil/fifo.c >>> index d741bdd395..f2f046b1f3 100644 >>> --- a/libavutil/fifo.c >>> +++ b/libavutil/fifo.c >>> @@ -20,14 +20,23 @@ >>> * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA >>> */ >>> >>> +#include >>> + >>> #include "avassert.h" >>> #include "common.h" >>> #include "fifo.h" >>> >>> +#define FIFO_SIZE_MAX FFMIN3((uint64_t)INT_MAX, (uint64_t)UINT32_MAX, (uint64_t)SIZE_MAX) >> >> Aren't these casts unnecessary? > > Possibly yes. I mainly added them so that FIFO_SIZE_MAX is always the > same type, which might prevent surprises. I can drop the casts if you > think they are never necessary. > FIFO_SIZE is the type that results after integer promotions of an expression involving an int, an uint32_t and a size_t parameter; all three constants are representable in it and FIFO_SIZE is representable in an int, an uint32_t and size_t. Given that it denotes a size I think you should cast it to size_t if you want to avoid surprises. >> And actually dangerous? (They add the implicit requirement that >> INT_MAX and SIZE_MAX fit into an uint64_t.) > > I'll grant you _theoretically_ dangerous - I've never heard of a > posix-compliant platform with sizeof(int) > 64. sizeof(int) > 8 you mean? (Or even better: UINT_MAX > UINT64_MAX.) > > And in any case that macro should be gone with the old API (was going to > include a patch scheduling its removal, but apparently forgot - will > send it later). > _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".