From patchwork Sat Feb 8 21:18:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marton Balint X-Patchwork-Id: 17721 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 3D4BC44B956 for ; Sat, 8 Feb 2020 23:19:06 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 29BB568B083; Sat, 8 Feb 2020 23:19:06 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from iq.passwd.hu (iq.passwd.hu [217.27.212.140]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id E26C768B083 for ; Sat, 8 Feb 2020 23:19:03 +0200 (EET) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 97321E3ABE; Sat, 8 Feb 2020 22:19:03 +0100 (CET) X-Virus-Scanned: amavisd-new at passwd.hu Received: from iq.passwd.hu ([127.0.0.1]) by localhost (iq.passwd.hu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id YSrz9CH7lANi; Sat, 8 Feb 2020 22:19:01 +0100 (CET) Received: from bluegene.passwd.hu (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 95248E3925; Sat, 8 Feb 2020 22:19:00 +0100 (CET) From: Marton Balint To: ffmpeg-devel@ffmpeg.org Date: Sat, 8 Feb 2020 22:18:16 +0100 Message-Id: <20200208211823.31345-5-cus@passwd.hu> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20200208211823.31345-1-cus@passwd.hu> References: <20200208211823.31345-1-cus@passwd.hu> Subject: [FFmpeg-devel] [PATCH 05/12] avformat/http: make sure URL path contains a slash 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: Marton Balint MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" It is explicitly required by the HTTP RFC. Without this patch URLs like http://example.com?query will not work. Fixes ticket #8466. Signed-off-by: Marton Balint --- libavformat/http.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/libavformat/http.c b/libavformat/http.c index 5411aa0f29..d0df1b6d58 100644 --- a/libavformat/http.c +++ b/libavformat/http.c @@ -193,7 +193,7 @@ static int http_open_cnx_internal(URLContext *h, AVDictionary **options) char *hashmark; char hostname[1024], hoststr[1024], proto[10]; char auth[1024], proxyauth[1024] = ""; - char path1[MAX_URL_SIZE]; + char path1[MAX_URL_SIZE], sanitized_path[MAX_URL_SIZE]; char buf[1024], urlbuf[MAX_URL_SIZE]; int port, use_proxy, err, location_changed = 0; HTTPContext *s = h->priv_data; @@ -220,10 +220,14 @@ static int http_open_cnx_internal(URLContext *h, AVDictionary **options) if (hashmark) *hashmark = '\0'; - if (path1[0] == '\0') + if (path1[0] == '\0') { path = "/"; - else + } else if (path1[0] == '?') { + snprintf(sanitized_path, sizeof(sanitized_path), "/%s", path1); + path = sanitized_path; + } else { path = path1; + } local_path = path; if (use_proxy) { /* Reassemble the request URL without auth string - we don't