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 B109645539 for ; Fri, 3 Mar 2023 12:48:20 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 4A49268B9EB; Fri, 3 Mar 2023 14:48:16 +0200 (EET) Received: from mail-pl1-f181.google.com (mail-pl1-f181.google.com [209.85.214.181]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 1787F68A861 for ; Fri, 3 Mar 2023 14:48:10 +0200 (EET) Received: by mail-pl1-f181.google.com with SMTP id p20so2490929plw.13 for ; Fri, 03 Mar 2023 04:48:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1677847688; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=n94NFchXpad4B9/BHYC3oD9rs5oEmTzC8pAH8ZG2rfo=; b=ZDAI0BDc7DJRq29qUtHtDlqeSGeQ8v/u9pggm8cW64ydeI7W1pwyyZG+n0M2IvzY4E /DOZyMbmptTlSCX3TkHUcgOJip5SmxcPM1M9+rB2U4+v/dD0OFujL1mdTNqGClW9qngp kIBdZ7n1KXFdYG3W6eMoo/bBYyjRf6rDAQ3DJEaVGy0hUj6lwSkQL4B73uL90ZgX3Qon QdvLwd/bPJB1SDtzdC4OmJOHR5fRhDJcTNbMCZL8HVEuZ1KVV/pG577jVA1uSg8qlvVo woV0Vgpfpl1yZEgCYYng+nGF97qX5hXzslbH6SN5UyOyDjonH7/C5ljz8ZTU3ocYzbvD 5hbA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1677847688; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=n94NFchXpad4B9/BHYC3oD9rs5oEmTzC8pAH8ZG2rfo=; b=wxBZyrMPHUeoiXPCz/9i72bbn1U/hgCfAYhELw9aNKZZk/oj68T/cNlE0C/Dn90htp oq1C9fUMby1q5S6962sdTyCxbXM3RGhb9yD62yHse6SZNP0ACdD0j3/Bqs3t3NTDJx2Z 0Wib1pRL318EdhKzw+gUn+wWeM9zrnrfYiDxbZGS7B6NxBVC25a9U3CnQCI/7qUk7Ena p82C+nadhtC1YlYKzBNK/K6CMFzjPm7vg2lPmDpL8Dwmb+W2PWpdjUW4yk6PHSLPA4ZC 3eRKJWw1rvTXLipPYM+nCDt8t5UJ9cQQit9Lqmz7hX+/qGdh2N6bsOPsHeLv0V8nLdty XR7g== X-Gm-Message-State: AO0yUKUvI5KPPMsR1B9cG6T9Ro/GmlQOoh04L3GsxZnJUF+9BnjowZuU IWEYG2CGQaflv9xgunOXT6QVurftaXqsXeBR0FE= X-Google-Smtp-Source: AK7set9LmXjp1JgK40xut2rHtZjg0jEp9oAcnDGpoL0WmE1RXZ+xKwtglkiPL9lH9V+k+M6KrLvRKw== X-Received: by 2002:a17:90b:1d88:b0:237:99b8:4eef with SMTP id pf8-20020a17090b1d8800b0023799b84eefmr1715952pjb.9.1677847687755; Fri, 03 Mar 2023 04:48:07 -0800 (PST) Received: from localhost.localdomain ([2409:8a28:5083:e220::51b]) by smtp.gmail.com with ESMTPSA id y14-20020a655b4e000000b0049f5da82b12sm1458048pgr.93.2023.03.03.04.48.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Mar 2023 04:48:07 -0800 (PST) From: jackarain To: ffmpeg-devel@ffmpeg.org Date: Fri, 3 Mar 2023 20:47:59 +0800 Message-Id: <20230303124759.1140538-1-jack.wgm@gmail.com> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] libavforamt/tls: Memory allocation failure check 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: jackarain 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: Signed-off-by: jackarain --- libavformat/tls.c | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/libavformat/tls.c b/libavformat/tls.c index e42d399862..b9d3426331 100644 --- a/libavformat/tls.c +++ b/libavformat/tls.c @@ -30,15 +30,18 @@ #include "libavutil/opt.h" #include "libavutil/parseutils.h" -static void set_options(TLSShared *c, const char *uri) +static int set_options(TLSShared *c, const char *uri) { char buf[1024]; const char *p = strchr(uri, '?'); if (!p) - return; + return 0; - if (!c->ca_file && av_find_info_tag(buf, sizeof(buf), "cafile", p)) + if (!c->ca_file && av_find_info_tag(buf, sizeof(buf), "cafile", p)) { c->ca_file = av_strdup(buf); + if (!c->ca_file) + return AVERROR(ENOMEM); + } if (!c->verify && av_find_info_tag(buf, sizeof(buf), "verify", p)) { char *endptr = NULL; @@ -47,11 +50,19 @@ static void set_options(TLSShared *c, const char *uri) c->verify = 1; } - if (!c->cert_file && av_find_info_tag(buf, sizeof(buf), "cert", p)) + if (!c->cert_file && av_find_info_tag(buf, sizeof(buf), "cert", p)) { c->cert_file = av_strdup(buf); + if (!c->cert_file) + return AVERROR(ENOMEM); + } - if (!c->key_file && av_find_info_tag(buf, sizeof(buf), "key", p)) + if (!c->key_file && av_find_info_tag(buf, sizeof(buf), "key", p)) { c->key_file = av_strdup(buf); + if (!c->key_file) + return AVERROR(ENOMEM); + } + + return 0; } int ff_tls_open_underlying(TLSShared *c, URLContext *parent, const char *uri, AVDictionary **options) @@ -63,8 +74,11 @@ int ff_tls_open_underlying(TLSShared *c, URLContext *parent, const char *uri, AV const char *proxy_path; char *env_http_proxy, *env_no_proxy; int use_proxy; + int ret; - set_options(c, uri); + ret = set_options(c, uri); + if (ret) + return ret; if (c->listen) snprintf(opts, sizeof(opts), "?listen=1"); -- 2.39.2 _______________________________________________ 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".