From patchwork Mon Jun 7 23:04:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Diederick C. Niehorster" X-Patchwork-Id: 28140 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:b214:0:0:0:0:0 with SMTP id b20csp3887718iof; Mon, 7 Jun 2021 16:07:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyhWeKeO0/vvvhilVsWiECJIkuegK+HsWtjAQ1sHUH2TaVAbtzctyoCGDDw964ZXAhVeRIm X-Received: by 2002:aa7:d5d6:: with SMTP id d22mr22239557eds.302.1623107253558; Mon, 07 Jun 2021 16:07:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623107253; cv=none; d=google.com; s=arc-20160816; b=Hkp5NfWSjBQoD/ltPdiOPXVsZI/gh7UrCmwZ2nxpkqwab2Sm9y5QNEOmIpr7zNjrJl hvs47VrhuTtt1hPAjUX3FU1MGntJUZRwNNKpqFypbGV3jcF6uZ/VmukkS9h0lvRyTaJT D885O0/UjAvUiwolI/ZC1Oo2L8QR8h3HC3ax1bUsuLXO8kDv/X9IvvbbLq+snPGXov5r Zf3IL09/8jbqnhD6K2exhnBy5OKOsSe86yYKjk4V4jkO8GrEbghDnxy9jm7MdYia43uj BE1NOdFDHL0jZvsrRWbDdxzzBP/igqMdZjs1Lw4WSk3FdQBZ0Dwvg1LLhbpEQuViYQa+ 8bww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:delivered-to; bh=dOV9fN6ZMF+6WHU3EeUtuS+ARRe7UP4KrjIw7eFWUk4=; b=q6MvE9hAQS/y/d+HBpVz4gShD/Vl8Ktd0VRw8bKF4Mj5/c7m7aO1TdPcacPp64QBm1 goJ3gGF6MtmmVJrKLRVk5pEF1znc4rNGurHeZ7fwnESw9QMA7D90JhZwRwFd0pq5GgSD IJ3duGVQj1F45A++yWI5Ae5501V1lS9GbDobdSD5sSsVeyqbWFbaie5cGtlhLSch7MJL Y+bfd6lQMWX9MGigfXCkRwqb9J7DzUDLFfWSxBGEGz+/XpDy8b2I6cvfh9b6UrPitZ7e Zb2pzzPbgfYFl9yUZa54eTORoApZ8SgRfaBUWfQJjgQt6nguhWhacrogXs5ZA6eL+Hh+ rb8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=BqiXqEEg; 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 j5si6496165ejj.184.2021.06.07.16.07.32; Mon, 07 Jun 2021 16:07:33 -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=BqiXqEEg; 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 7C0C3688115; Tue, 8 Jun 2021 02:05:03 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-lf1-f50.google.com (mail-lf1-f50.google.com [209.85.167.50]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 57DB3687FFE for ; Tue, 8 Jun 2021 02:04:59 +0300 (EEST) Received: by mail-lf1-f50.google.com with SMTP id w33so29021217lfu.7 for ; Mon, 07 Jun 2021 16:04:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=0IwTtKkxgdS0nvnjOpfSRmxRTQwAlAfg2KTd0EUpX08=; b=BqiXqEEgpk+h6ldThEOCjAoc8IFjCRP8LRkMWXDlz9eFEQXLA0VvScDNyp2Q8bXNrv +cOr4wRzqLRWWt9Z2DPhR+K5JSn5ZLLVWBoCXgxXqwpl0h9duQULgRSRV4kZAY4nwroP VQAQJGFW0WXptuN3+fNTyNM7kKiC03mNX4B74h0+xNwHfjBX4nWkaw2o5vfVXfXzRNsw pHtJzYWBYHv5ZkiL7wa88yc9DSB4hzl/TKRdSG6xZ60I92oKFADtylgUVC6NsOuCAFTc 4wy6y/B4nZrVaQwwIw176+3JvneSXVaLV5rBVNM14YlOSjylHc63J4GChkEMfPVeA4/k NRPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=0IwTtKkxgdS0nvnjOpfSRmxRTQwAlAfg2KTd0EUpX08=; b=SasIKgb6FAkiP/SPjj9qDTUMDHzCFBQVvPlqQ3Ths0WjHQ2VydtxuHHCYlJFAaimyX 3Rd2AyE21PzCVkY3AbZ9KnL0JNZPgnOW+V5JgXImY3R7gDco7xdWRpSx27naxIubdo3j KUQZGmlRuZRSmL6qSY3JfYLH62z0Tp4Yac7es0wh2NQASqKs3aXb9Ezi0v83YRLBhTTo QsoWlhxdRj0np+eFj522XBZS+yJgUNQy6Q6Y8nw8rsfAFwtFp+JJ4E7pZjodyqj9GMaJ k5Y1Vm0vckv9nFL6n7aqfneLlCmGlt3yQ0lZuJyhzuFjinuYOgyox28rG2fEsxHUo+XY E9Lg== X-Gm-Message-State: AOAM530imJIYOsfQ8M4eA4QSI/LP7oMG5keVyZWn/aknaAn78oQXn6dy GrNLSxw5V8m1aJr0nFnMu6SzS3e3RCdH4w== X-Received: by 2002:a05:6512:1693:: with SMTP id bu19mr11537890lfb.569.1623107098354; Mon, 07 Jun 2021 16:04:58 -0700 (PDT) Received: from localhost.localdomain (84-217-56-54.customers.ownit.se. [84.217.56.54]) by smtp.gmail.com with ESMTPSA id v9sm1999563ljv.131.2021.06.07.16.04.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Jun 2021 16:04:57 -0700 (PDT) From: Diederick Niehorster To: ffmpeg-devel@ffmpeg.org Date: Tue, 8 Jun 2021 01:04:13 +0200 Message-Id: <20210607230414.612-35-dcnieho@gmail.com> X-Mailer: git-send-email 2.28.0.windows.1 In-Reply-To: <20210607230414.612-1-dcnieho@gmail.com> References: <20210607230414.612-1-dcnieho@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 34/35] avdevice/dshow: prevent NULL access 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: Diederick Niehorster Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: 6KQ15r0m25oz list_options true would crash when both a video and an audio device were specified as input. Crash would occur on line 1618 (in this new rev) because ctx->device_unique_name[otherDevType] would be NULL Signed-off-by: Diederick Niehorster --- libavdevice/dshow.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libavdevice/dshow.c b/libavdevice/dshow.c index c158a536d8..9af3360317 100644 --- a/libavdevice/dshow.c +++ b/libavdevice/dshow.c @@ -1503,9 +1503,9 @@ dshow_list_device_options(AVFormatContext *avctx, ICreateDevEnum *devenum, if ((r = dshow_cycle_devices(avctx, devenum, devtype, sourcetype, &device_filter, &device_unique_name, NULL)) < 0) return r; ctx->device_filter[devtype] = device_filter; + ctx->device_unique_name[devtype] = device_unique_name; if ((r = dshow_cycle_pins(avctx, devtype, sourcetype, device_filter, ranges ? &device_pin : NULL, ranges, query_type)) < 0) return r; - av_freep(&device_unique_name); return 0; } @@ -1565,7 +1565,8 @@ dshow_open_device(AVFormatContext *avctx, ICreateDevEnum *devenum, goto error; } } - if (ctx->device_filter[otherDevType]) { + + if (ctx->device_filter[otherDevType]) { // avoid adding add two instances of the same device to the graph, one for video, one for audio // a few devices don't support this (could also do this check earlier to avoid double crossbars, etc. but they seem OK) if (strcmp(device_filter_unique_name, ctx->device_unique_name[otherDevType]) == 0) { @@ -2027,6 +2028,7 @@ static int dshow_read_header(AVFormatContext *avctx) } } } + // don't exit yet, allow it to list crossbar options in dshow_open_device } ctx->is_running = 0; if (ctx->device_name[VideoDevice]) {