From patchwork Fri Jun 11 20:31:03 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: 28233 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a5e:c91a:0:0:0:0:0 with SMTP id z26csp767461iol; Fri, 11 Jun 2021 13:40:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxDT4MvEojADLdnBQLjhm9YStRWMoWl2w6dnlUlhc52FBu/efyBDnyro6f+pmNKzvZASB20 X-Received: by 2002:a17:906:26ce:: with SMTP id u14mr5180439ejc.187.1623444053970; Fri, 11 Jun 2021 13:40:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623444053; cv=none; d=google.com; s=arc-20160816; b=bJBdpJkY+uAGGYkP1xmjAW1M8CeTn5b/yQPTOTksB1YRDupW98aIvlomqkFehyAaIj C6gnUGKJlgDIeyNGbyj0sMZfpiflmL4qDXInj9OT3XmeCgNhp8no/1wwom2qPGIHCQOp 5k52hmBy5Iaa+C6a7aFj20OFqGJQP0gmWzldMoZ/TMZjTFewrZucoTFsSNwrJYu2H9qc i6a06jU7MoUVsA66y4dUH0zoMLmOMqugcoesVCfzsrnPxtKmAsHKDzPrMF+TduYzMWCN BgXRIXE2BvrGthUJMVdQ9hr/t+3rWep24kJUGI0hCDMEsWOrtIEDb6jI3O+/skMvZARe jjaw== 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=3a1pVSTSNj3anxIlcIJPQkwNBvhenGn6cUvC7shf9Yk=; b=GxWuSAeZD3tb/R7rakh1HjlatdZU6WPgKTa4QyjWPHoMUXSWx4FRnbdQzdoqKXRMCD Rh9j3sKK/7c2vLEEqbpDyG2EtsYtBX+YdKwVXczsQkVvrg3uUKjnoLDt/Qr4L0SThwJ7 +mGmNGssJPZYjXmUdnVHIOOKlO+ly0SwX0aWDmrcQFyo5isjKp83NvGwaotXfFwiwPeH l1IZWCqr1ub2UL16ET0aFiNANYHu2kJuDTTny1dnlMyoR9/uIVxIVUPZ9hjCFUS4LneN KQ/RN7GgBafootPawSX00/5La5G5j2wG7hEdK4EIJO7h4PpruebyWt3LTLSmQx8I88TS t3hQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=V18FNSIe; 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 f10si5603787ejt.614.2021.06.11.13.40.53; Fri, 11 Jun 2021 13:40:53 -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=V18FNSIe; 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 B1967689C2B; Fri, 11 Jun 2021 23:40:43 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-lf1-f44.google.com (mail-lf1-f44.google.com [209.85.167.44]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 42E2A689B33 for ; Fri, 11 Jun 2021 23:40:41 +0300 (EEST) Received: by mail-lf1-f44.google.com with SMTP id p17so10383105lfc.6 for ; Fri, 11 Jun 2021 13:40:41 -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=TcbjFB1/FSqcF2QcLiWCLVDIfPj88HwUoK0ieNEXDuk=; b=V18FNSIe1tZC+wLlHFioY47HguinjKNHjFHy4DQYq0egTO51iTQIw5xhWu7nZnaw2k 3OxJoXfs8YbK0FNLFE1SxBvp3iuEa//qc66e8tWI86sqvO9rD8hSXKpkyc1kX6NjpcEb W9LHMtRlEZxQqWL3R2SI9ISNauP24xpqdToYzftY4rpBm7PN0m9CF2yxcYRufVjbAbi2 Ti+DNrzNpCSj/BccFcq5JJOApbjKilHHIyIAsMc8Dh8ECZI9klzAYjAFR3z3yorqzVls NreZPw0eHTyAJddMHZ/ra/qpHo6fw+z2QVv+3UJeBeL59IICn66VcRy9EOJs4XrDpd9E OgAw== 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=TcbjFB1/FSqcF2QcLiWCLVDIfPj88HwUoK0ieNEXDuk=; b=qYxmiAPU5CrJUtOdMzfq206P83p+Kng0CLLmN1ZGNtERiqFjmUGPniB7gIM/yI7S80 sjPBO33px4eQC4MwDJAR/LNy0ge0rT8OPLvhlB2oqhpr/wTQ3WLxhJv2vM2udWc35Ijk A/Rj8upgSXAUIbTyUlRXaNUBiEQTDVii5i5WBqs6jCDCPENT0w7XdAwKu9MOZ/x7JLxe +k544NedYbJAG8zq8sQBDLUBa8w1fDWVsk27486xqFlTNYcxnQGwum6resakHKO0kznl 6mk5Sw2Ndo3ZCzVYldwRA1JcWwYvZ+P/KFfhPwrfsNcmRi1UyB6rtf7kzZa8Dki5txV4 2a7A== X-Gm-Message-State: AOAM533JvQhHsakmeBEChPp/XdmT+gfIc2CVxsAcxuIW77zbNTMNTx38 3k/S1tJvEE9Fj6lNjdxmCT6gTjPyJmnjNA== X-Received: by 2002:a05:6512:3d8f:: with SMTP id k15mr3893652lfv.362.1623444040372; Fri, 11 Jun 2021 13:40:40 -0700 (PDT) Received: from localhost.localdomain ([196.196.203.214]) by smtp.gmail.com with ESMTPSA id q184sm906143ljb.54.2021.06.11.13.40.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Jun 2021 13:40:39 -0700 (PDT) From: Diederick Niehorster To: ffmpeg-devel@ffmpeg.org Date: Fri, 11 Jun 2021 22:31:03 +0200 Message-Id: <20210611203104.1692-33-dcnieho@gmail.com> X-Mailer: git-send-email 2.28.0.windows.1 In-Reply-To: <20210611203104.1692-1-dcnieho@gmail.com> References: <20210611203104.1692-1-dcnieho@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2 32/33] 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: 7G69SPQEc8K1 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 92cfaa062d..d3937df41a 100644 --- a/libavdevice/dshow.c +++ b/libavdevice/dshow.c @@ -1516,9 +1516,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; } @@ -1578,7 +1578,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) { @@ -2040,6 +2041,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]) {