From patchwork Sat Mar 6 13:07:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 26216 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 45E2E44B3F6 for ; Sat, 6 Mar 2021 15:07:58 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 1DDA568A429; Sat, 6 Mar 2021 15:07:58 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-ed1-f51.google.com (mail-ed1-f51.google.com [209.85.208.51]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 8A87568814E for ; Sat, 6 Mar 2021 15:07:51 +0200 (EET) Received: by mail-ed1-f51.google.com with SMTP id v13so6917550edw.9 for ; Sat, 06 Mar 2021 05:07:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=vkfQCF2mPOczruGn0UTX0vDmopK0Rn+CS1xGM3Aiv+0=; b=DGFxINujg+P82Gk32vAjaz19IQf93fJdbn94o8+8sfTg9FsUp9HnWNC8MDz4UlKPI8 DObKZw0m4WFqznhdD2/bhOWKnB65G/Xe3Zvz8ID589HKgGO2sd0nsy9jfh08ZomiBNPN ddWuN7a6XvN/PKbqJT4IIqzx5VC1I7l+ZCKdrZK3s2SD1QWXMqS6mo8U7rWkfrg2pqzC Gc4W2/qQIfJlMFaaQFC2DBgyTFiwbRgRL3Qhb9kCcuqq406OxNWNd2t+euRZUvX479V7 kOMDn84L1VGQXKAe/QJYxnXcFEqgX8duuD+RKswJ2sReBvZvzmx/CJDdYET3FUJkizFW tWrQ== 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:mime-version :content-transfer-encoding; bh=vkfQCF2mPOczruGn0UTX0vDmopK0Rn+CS1xGM3Aiv+0=; b=S34PnhJNXU9WkTqqkkPezfQRl1cDrxz7YsAGrsgQlaDD5hOxXeZKGzR0HlMxgqT+10 7yqQjthN21bb5kCnj8tyJW/A6U3N5sx7y17Du0roSf7hZhsNf9k6KPGDq6jvnuUjQWoi 7/VArt1Qm/r3HnaHcU8EWgrSJzOd8bLEMKmMFe0rXeBCXrIOHEpBvvIi00gDMMXECV7D NJSxs1UJE4a90P6RHr137H2uuvRf6SGlCA7gv4Sy80PpH4VChnQ9d9iJ0yaFU7ixMvGQ MsM3zWGeUO8vy0JOLaHT2O+xxRlTXM/aCVpLHtjvQ98drLR1pS1fyVVSOc2n2ew14qh6 8T9Q== X-Gm-Message-State: AOAM530H43GRuBaDVIoabRUAcq0oFDqkoRtjyUH4M9j4gpeFJxUUNQWR AHS831je9omFF7FCkcFBbEc3RmYA4h4= X-Google-Smtp-Source: ABdhPJxLY/LmMJ1ouT4u0yX99lYgN6xTxg9NwcF8hQUpnOPs4RBJ4BAotJKN3r0Ep/Xlc5Uug+txOg== X-Received: by 2002:a05:6402:8d7:: with SMTP id d23mr14051021edz.256.1615036070792; Sat, 06 Mar 2021 05:07:50 -0800 (PST) Received: from sblaptop.fritz.box (ipbcc1aa4b.dynamic.kabel-deutschland.de. [188.193.170.75]) by smtp.gmail.com with ESMTPSA id h10sm3638365edk.17.2021.03.06.05.07.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 06 Mar 2021 05:07:50 -0800 (PST) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Sat, 6 Mar 2021 14:07:44 +0100 Message-Id: <20210306130744.780447-1-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] avformat/http: Fix leak when using deprecated option 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 Cc: Andreas Rheinhardt Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" When the deprecated option "user-agent" was set to something different than its default value, said option would always precede and overwrite the ordinary user_agent option (regardless of whether it was explicitly set) which leads to a leak of the user_agent option (which has a default value, so the leak happens always). Fix this by setting the same destination for both options; the last option applied wins then. Signed-off-by: Andreas Rheinhardt --- libavformat/http.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/libavformat/http.c b/libavformat/http.c index c5df1def62..d44bc64f7b 100644 --- a/libavformat/http.c +++ b/libavformat/http.c @@ -78,9 +78,6 @@ typedef struct HTTPContext { char *http_version; char *user_agent; char *referer; -#if FF_API_HTTP_USER_AGENT - char *user_agent_deprecated; -#endif char *content_type; /* Set if the server correctly handles Connection: close and will close * the connection after feeding us the content. */ @@ -145,7 +142,7 @@ static const AVOption options[] = { { "user_agent", "override User-Agent header", OFFSET(user_agent), AV_OPT_TYPE_STRING, { .str = DEFAULT_USER_AGENT }, 0, 0, D }, { "referer", "override referer header", OFFSET(referer), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, D }, #if FF_API_HTTP_USER_AGENT - { "user-agent", "use the \"user_agent\" option instead", OFFSET(user_agent_deprecated), AV_OPT_TYPE_STRING, { .str = DEFAULT_USER_AGENT }, 0, 0, D|AV_OPT_FLAG_DEPRECATED }, + { "user-agent", "use the \"user_agent\" option instead", OFFSET(user_agent), AV_OPT_TYPE_STRING, { .str = DEFAULT_USER_AGENT }, 0, 0, D|AV_OPT_FLAG_DEPRECATED }, #endif { "multiple_requests", "use persistent connections", OFFSET(multiple_requests), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, D | E }, { "post_data", "set custom HTTP post data", OFFSET(post_data), AV_OPT_TYPE_BINARY, .flags = D | E }, @@ -1321,12 +1318,6 @@ static int http_connect(URLContext *h, const char *path, const char *local_path, } } -#if FF_API_HTTP_USER_AGENT - if (strcmp(s->user_agent_deprecated, DEFAULT_USER_AGENT)) { - s->user_agent = av_strdup(s->user_agent_deprecated); - } -#endif - av_bprintf(&request, "%s ", method); bprint_escaped_path(&request, path); av_bprintf(&request, " HTTP/1.1\r\n");