From patchwork Sun Jun 10 12:26:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Derek Buitenhuis X-Patchwork-Id: 9356 Delivered-To: ffmpegpatchwork@gmail.com Received: by 2002:a02:11c:0:0:0:0:0 with SMTP id c28-v6csp2984551jad; Sun, 10 Jun 2018 05:27:02 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKY1Jwl1N7YsbQKZrhqB+h60B+Sbne6dUtyRT/wYMX2mMdtrlxaG6472pAgovVirdAgzul6 X-Received: by 2002:adf:aadd:: with SMTP id i29-v6mr9986209wrc.149.1528633622191; Sun, 10 Jun 2018 05:27:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528633622; cv=none; d=google.com; s=arc-20160816; b=mFWgQB0FRv5TpdmSxreIdIYD100s9Ngr+xbKYfr38sO1zH7kFyXaaukcT6P7rCiARS ZOryNXkEHHFjLBXWnGgQgQOOLQ/+Ftc4mv2bOLzt74kNmD8ACxFPl07dhDx85LSB7jG8 6dSLJz4GRJp3/jFcOaBSGuGfLyRbUY95aKVQXrhXpxzUS8nergQS3/SEHvSdTTpu9Y/X GXHxrKAVy14PkzgZwLjPLYJ4tqzci7IhwS/gK+r5YChZrWdwx5PnCO1+bWTy/S8UVQnR gF0NN+cLc0Ubm3b8wvkcP7DCd7PfGk+91AGDjEQwhlrqiIPtoEkMEVf/YU9gFqPZWxbc yqMw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:dkim-signature:delivered-to:arc-authentication-results; bh=3YOS72eOVPwfJwoLByBAypur44zd8va5V+p6r9MulT4=; b=L/Fm++jTv+QSDo0oY18mHIHBAjR6fBgR3gMna0drAMc/zgVUrHm0uBKYRkm9KJLJRs O1YoxG88sKvMMv3//osrNIY+uecXfSq+iVrWkxC7RR5o5X6xamQjRO1by08XqsSm2Zb3 Lox4zFmcLJQfZJEiIv/YURVmMcdDPWu+p39FfZ4OJUE3CMq46ljPPREsJuXbejBcMvX1 Lm8/1C2L/sjRbu8IW3G3OdvOLRcc0jkXU6x5t1nAM+iDX4v6/Xpt02S6qpHF/elVTSeo BnMJKg25JC4QEO9FGowwuTqh//UXpEAVydSDNk9gE3kIffaUep4v8zAlkBxqSg3Pc1o3 WsNw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=Y67OGCmO; 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=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id s126-v6si4421968wmb.18.2018.06.10.05.27.01; Sun, 10 Jun 2018 05:27: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=@gmail.com header.s=20161025 header.b=Y67OGCmO; 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=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 8097868A8ED; Sun, 10 Jun 2018 15:26:10 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm0-f46.google.com (mail-wm0-f46.google.com [74.125.82.46]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 2124068A807 for ; Sun, 10 Jun 2018 15:26:04 +0300 (EEST) Received: by mail-wm0-f46.google.com with SMTP id n5-v6so11394409wmc.5 for ; Sun, 10 Jun 2018 05:26:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references; bh=qVFLArXCDQe0ZkKI36mmT8OeG3+/1Lh/cz9iwDrSzOk=; b=Y67OGCmOV3Ddt9TKA7egOFsbMkGP4bToyeEvZ4H2geJPlCQ21RfxiuAlOyz3WLWTxk poiXA4JkekCYdqVtr1Aup0Eyf+yQEnwz9ed2NOXA83eOnYgguPHWp1GXfzhTQDlC24Vt EP2hAx9Q3I+PYxzDJ5wYJh3lAjL10HVVJbNnBJ4JWY7b7fcbmGLOmTz3/mnV6ZD9z9yd Z2CUPE+spAIn3SJdjKtPP2eupAlqfcfQZjS59FydQArHlOtwL7OD1xrTvntZiZCRWVrY nTXI8BfhPvdbvYObCkGP77WtdObxbu5g7yMJnZM+aPoAkgfVTL/qG8qEL3WYhLNQzibM ihfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=qVFLArXCDQe0ZkKI36mmT8OeG3+/1Lh/cz9iwDrSzOk=; b=nZAfRVkl5yULmYjHDHk9sDxpetSz24Bd94GE6b0iWHhtncXzyuw2aYgkkV08clgR7e N8TYQiuOk+2ODael4VAwmadDkFuiOSGjMjo5f0c3pB/r6HRF46M3YoA9Ws3xLiBJ6LS0 4XfyWYnNGYcMpH+68jrtUCoyZa9FZ3SaKermN2ojtcCGajLGWmYW5HwWeU6n/PXDJFzA WoJYxIXu4jQnA4ATyhMgPE//gDxB9irB8OPy8sSV0JASeFQHzrhGv+ydGyM5NpMFsGp+ o89njxx4LveS9eaEb81NcTVZGtWFN4iXkbwDcUyctqnxj+BnblrXm8C4hiW6tk7Zju2P LibA== X-Gm-Message-State: APt69E08nGGOYQJfPCyMeGGpPRrYfJwazzqV1K/AgT2RQWxSWX7daFwx K+UMZjy9qvKUBHWkrHUy9+2GWTq1 X-Received: by 2002:a1c:574b:: with SMTP id l72-v6mr6096546wmb.56.1528633612004; Sun, 10 Jun 2018 05:26:52 -0700 (PDT) Received: from localhost.localdomain ([81.2.162.105]) by smtp.gmail.com with ESMTPSA id x5-v6sm35481665wrr.3.2018.06.10.05.26.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 10 Jun 2018 05:26:51 -0700 (PDT) From: Derek Buitenhuis To: ffmpeg-devel@ffmpeg.org Date: Sun, 10 Jun 2018 13:26:43 +0100 Message-Id: <20180610122643.145302-1-derek.buitenhuis@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180608154705.144075-1-derek.buitenhuis@gmail.com> References: <20180608154705.144075-1-derek.buitenhuis@gmail.com> Subject: [FFmpeg-devel] [PATCH v2] pixdesc: Only check against valid entries when iterating over lists of enums X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 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 MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Some of these enums have gaps in between their values, since they correspond to the values in various specs, instead of being an incrementing list. Fixes segfaults when, for example, using the valid API call: av_color_primaries_from_name("jecdec-p22"); Signed-off-by: Derek Buitenhuis --- libavutil/pixdesc.c | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/libavutil/pixdesc.c b/libavutil/pixdesc.c index ff5c20d50e..96e079584a 100644 --- a/libavutil/pixdesc.c +++ b/libavutil/pixdesc.c @@ -2737,7 +2737,12 @@ int av_color_primaries_from_name(const char *name) int i; for (i = 0; i < FF_ARRAY_ELEMS(color_primaries_names); i++) { - size_t len = strlen(color_primaries_names[i]); + size_t len; + + if (!color_primaries_names[i]) + continue; + + len = strlen(color_primaries_names[i]); if (!strncmp(color_primaries_names[i], name, len)) return i; } @@ -2756,7 +2761,12 @@ int av_color_transfer_from_name(const char *name) int i; for (i = 0; i < FF_ARRAY_ELEMS(color_transfer_names); i++) { - size_t len = strlen(color_transfer_names[i]); + size_t len; + + if (!color_transfer_names[i]) + continue; + + len = strlen(color_transfer_names[i]); if (!strncmp(color_transfer_names[i], name, len)) return i; } @@ -2775,7 +2785,12 @@ int av_color_space_from_name(const char *name) int i; for (i = 0; i < FF_ARRAY_ELEMS(color_space_names); i++) { - size_t len = strlen(color_space_names[i]); + size_t len; + + if (!color_space_names[i]) + continue; + + len = strlen(color_space_names[i]); if (!strncmp(color_space_names[i], name, len)) return i; } @@ -2794,7 +2809,12 @@ int av_chroma_location_from_name(const char *name) int i; for (i = 0; i < FF_ARRAY_ELEMS(chroma_location_names); i++) { - size_t len = strlen(chroma_location_names[i]); + size_t len; + + if (!chroma_location_names[i]) + continue; + + len = strlen(chroma_location_names[i]); if (!strncmp(chroma_location_names[i], name, len)) return i; }