Bug 1658574

Summary: curl: does not return error when downloading file and file already exists
Product: [Fedora] Fedora Reporter: Bruno Goncalves <bgoncalv>
Component: curlAssignee: Kamil Dudka <kdudka>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: medium    
Version: 29CC: astepano, john.j5live, kdudka, paul
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: curl-7.63.0-3.fc30 curl-7.61.1-6.fc29 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2018-12-23 02:52:44 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1660827    

Description Bruno Goncalves 2018-12-12 12:38:01 UTC
Description of problem:
I'm not sure if this is a bug or intended change, but on Fedora 28 (curl-7.59.0-9.fc28.x86_64) running the command below would not append the output to the file if it already exists.

Version-Release number of selected component (if applicable):
curl-7.61.1-1.fc30.x86_64

How reproducible:
100%

Steps to Reproduce:
1. curl --retry 5 --insecure --fail --location --show-error --remote-name --remote-header-name "https://copr.fedorainfracloud.org/coprs/mvadkert/beakerlib-libraries/repo/fedora-rawhide/mvadkert-beakerlib-libraries-fedora-rawhide.repo"

2. curl --retry 5 --insecure --fail --location --show-error --remote-name --remote-header-name "https://copr.fedorainfracloud.org/coprs/mvadkert/beakerlib-libraries/repo/fedora-rawhide/mvadkert-beakerlib-libraries-fedora-rawhide.repo"

3. cat mvadkert-beakerlib-libraries.repo 
[mvadkert-beakerlib-libraries]
name=Copr repo for beakerlib-libraries owned by mvadkert
baseurl=https://copr-be.cloud.fedoraproject.org/results/mvadkert/beakerlib-libraries/fedora-rawhide-$basearch/
type=rpm-md
skip_if_unavailable=True
gpgcheck=1
gpgkey=https://copr-be.cloud.fedoraproject.org/results/mvadkert/beakerlib-libraries/pubkey.gpg
repo_gpgcheck=0
enabled=1
enabled_metadata=1[mvadkert-beakerlib-libraries]
name=Copr repo for beakerlib-libraries owned by mvadkert
baseurl=https://copr-be.cloud.fedoraproject.org/results/mvadkert/beakerlib-libraries/fedora-rawhide-$basearch/
type=rpm-md
skip_if_unavailable=True
gpgcheck=1
gpgkey=https://copr-be.cloud.fedoraproject.org/results/mvadkert/beakerlib-libraries/pubkey.gpg
repo_gpgcheck=0
enabled=1
enabled_metadata=1

Actual results:
the content of mvadkert-beakerlib-libraries.repo is duplicated as curl appended the file.

Expected results:
At least on Fedora 28 (curl-7.59.0-9.fc28.x86_64) the 2nd execution of curl would return:
curl --retry 5 --insecure --fail --location --show-error --remote-name --remote-header-name "https://copr.fedorainfracloud.org/coprs/mvadkert/beakerlib-libraries/repo/fedora-rawhide/mvadkert-beakerlib-libraries-fedora-rawhide.repo"
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0Warning: Refusing to overwrite mvadkert-beakerlib-libraries.repo: File exists
100   386  100   386    0     0   1398      0 --:--:-- --:--:-- --:--:--  1398
curl: (23) Failed writing body (0 != 386)


Additional info:
On Fedora29 curl also appends the file

Comment 1 Kamil Dudka 2018-12-17 09:15:06 UTC
No I do not think it is intended.  This was first broken by the following commit, causing the destination file to be silently overwritten:

    https://github.com/curl/curl/commit/curl-7_60_0-17-gc1c27625c

Then it was supposedly fixed by the following commit:

    https://github.com/curl/curl/commit/curl-7_61_0-46-ge78f2cfe5

However, as you suggest, it is still not perfect...

Comment 2 Kamil Dudka 2018-12-17 09:28:55 UTC
Reported upstream: https://github.com/curl/curl/issues/3380

Comment 3 Kamil Dudka 2018-12-19 09:34:08 UTC
Upstream commit: https://github.com/curl/curl/commit/curl-7_63_0-17-g484926719

Comment 4 Fedora Update System 2018-12-19 15:51:06 UTC
curl-7.61.1-6.fc29 has been submitted as an update to Fedora 29. https://bodhi.fedoraproject.org/updates/FEDORA-2018-7bfb18eb6a

Comment 5 Fedora Update System 2018-12-21 21:05:37 UTC
curl-7.61.1-6.fc29 has been pushed to the Fedora 29 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2018-7bfb18eb6a

Comment 6 Fedora Update System 2018-12-23 02:52:44 UTC
curl-7.61.1-6.fc29 has been pushed to the Fedora 29 stable repository. If problems still persist, please make note of it in this bug report.