From patchwork Sat Dec 28 10:52:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Fotyev V." X-Patchwork-Id: 17020 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 C219C449FFD for ; Sat, 28 Dec 2019 14:48:11 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id A56D0689AA6; Sat, 28 Dec 2019 14:48:11 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-lj1-f193.google.com (mail-lj1-f193.google.com [209.85.208.193]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 7822668831D for ; Sat, 28 Dec 2019 14:48:04 +0200 (EET) Received: by mail-lj1-f193.google.com with SMTP id y4so14850331ljj.9 for ; Sat, 28 Dec 2019 04:48:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=to:from:subject:message-id:date:user-agent:mime-version :content-transfer-encoding:content-language; bh=1MgUW0l5SJ0TPebdMOzW2stTPo9BgwhoxkoMRg6SgUw=; b=JY3JF5pcLG6WxlB8WrEZuQ81dKG+Dsf3T1bDtGQQr0/DymAoBBZNvYyhjfD4F4h7Gd 663ijzB4MP5yvw0yZF+/YQVBBgWD9Lyn2bsB+eLY/WjPuWlaR/9tUlbzr6QvCM9e9zr0 gxLy3uZvzJ+OgLA0Bl3z7ZGT5fnyoxOpEYcD24xzwALJFjnX8hem4Z1fPKazqd5rU/91 AcKe7Q1g8Zy6DHyxr7w2TjsJHZnBnYcLaKDfXzlH3FIjL6t3VdJ96uG/B8XR3mpOX1ki OZ6csJvUHQkCsxjcRPLyn2jkpx96/be4vHZg4fjxlk++5tvMQOW9/nooFmQvon2RDGPR 32Ww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:from:subject:message-id:date:user-agent :mime-version:content-transfer-encoding:content-language; bh=1MgUW0l5SJ0TPebdMOzW2stTPo9BgwhoxkoMRg6SgUw=; b=COCWlCw/r2Se1pcIXcn895fZpoPdELOWK09ZAI/WV19Mzxfxhttl2+pxdnvbO2um98 KWz7CtA3zqFV2T9F3hVAF+YHANx1MRTb3G/A8DgFuAloDph0OR6Up9hTasKWqJPpp3X9 Os5+Eyd2344b9Y+vFKB2IpMThiaB0ThzUEoiOsDvURNlEDt43Tv3r8By408DarI2Rhrx Ds1Yp6U2K5HxJm/wbmAsK42Ok2BjLKzZI1FMAfGEZXEfa/6j+xToaahhEzxswfQ4ECSe xNR03iBQ/kKZ2W4GIxIjbrFMn1/Ch6Po84MXp4AlvO9FA2q+pqM03phG8xDQMG2cbv98 Y9lA== X-Gm-Message-State: APjAAAXyH+NOp0JLjDj+7i1rxnP/ek7HA/1rtzs1U/2arejKk+6pqdWY zxOIIxuJc8TYhFrqoVZmQLBC9Rg= X-Google-Smtp-Source: APXvYqw5/M26AZ4ud10F1cVyQx6YkMslNjMmndWbWjaWPVOCecjTI7r3SiSbsN1sEQ3W6Db+k68Tww== X-Received: by 2002:a05:651c:32b:: with SMTP id b11mr31845234ljp.203.1577537283506; Sat, 28 Dec 2019 04:48:03 -0800 (PST) Received: from [192.168.2.106] (nat-79-173-83-158.gtn.ru. [79.173.83.158]) by smtp.gmail.com with ESMTPSA id e9sm7730804ljp.75.2019.12.28.04.48.02 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 28 Dec 2019 04:48:02 -0800 (PST) To: ffmpeg-devel@ffmpeg.org From: "Fotyev V." Message-ID: Date: Sat, 28 Dec 2019 13:52:04 +0300 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:68.0) Gecko/20100101 Thunderbird/68.3.1 MIME-Version: 1.0 Content-Language: en-US Subject: [FFmpeg-devel] [PATCH] avformat/ftp: Exit with error on ftp_open if file does not exist 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Add a check for code 550 when requesting file size ---  libavformat/ftp.c | 11 +++++++++--  1 file changed, 9 insertions(+), 2 deletions(-) @@ -723,10 +727,13 @@ static int ftp_open(URLContext *h, const char *url, int flags)      if ((err = ftp_connect(h, url)) < 0)          goto fail; +    if ((err = ftp_file_size(s)) == AVERROR(ENOENT)) +        goto fail; +      if (ftp_restart(s, 0) < 0) {          h->is_streamed = 1;      } else { -        if (ftp_file_size(s) < 0 && flags & AVIO_FLAG_READ) +        if (err < 0 && flags & AVIO_FLAG_READ)              h->is_streamed = 1;          if (s->write_seekable != 1 && flags & AVIO_FLAG_WRITE)              h->is_streamed = 1; -- 2.17.1 diff --git a/libavformat/ftp.c b/libavformat/ftp.c index 97ad80d..64a5250 100644 --- a/libavformat/ftp.c +++ b/libavformat/ftp.c @@ -391,13 +391,17 @@ static int ftp_file_size(FTPContext *s)      char command[CONTROL_BUFFER_SIZE];      char *res = NULL;      static const int size_codes[] = {213, 0}; +    int resp_code;      snprintf(command, sizeof(command), "SIZE %s\r\n", s->path); -    if (ftp_send_command(s, command, size_codes, &res) == 213 && res && strlen(res) > 4) { +    resp_code = ftp_send_command(s, command, size_codes, &res); +    if (resp_code == 213 && res && strlen(res) > 4) {          s->filesize = strtoll(&res[4], NULL, 10);      } else {          s->filesize = -1;          av_free(res); +        if (resp_code == 550) +            return AVERROR(ENOENT);          return AVERROR(EIO);      }