Skip to content

[bug] -R Failed to set filetime, -o file name has Full-width character #5658

Closed

Description

@tec1987

I did this

D:\>curl https://dl.bintray.com/vszakats/generic/curl-7.71.1-win32-mingw.tar.xz.asc -R -O
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   821  100   821    0     0    172      0  0:00:04  0:00:04 --:--:--   172

D:\>curl https://dl.bintray.com/vszakats/generic/curl-7.71.1-win32-mingw.tar.xz.asc -R -o cc.asc
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   821  100   821    0     0    398      0  0:00:02  0:00:02 --:--:--   398

D:\>curl https://dl.bintray.com/vszakats/generic/curl-7.71.1-win32-mingw.tar.xz.asc -R -o 校验.asc
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   821  100   821    0     0    509      0  0:00:01  0:00:01 --:--:--   509
Failed to set filetime 1593598063 on outfile: CreateFile failed: GetLastError 2

D:\>curl https://dl.bintray.com/vszakats/generic/curl-7.71.1-win32-mingw.tar.xz.asc -R -o ".\temp\校验.asc"
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   821  100   821    0     0    130      0  0:00:06  0:00:06 --:--:--   201
Failed to set filetime 1593598063 on outfile: CreateFile failed: GetLastError 2

D:\>curl https://dl.bintray.com/vszakats/generic/curl-7.71.1-win32-mingw.tar.xz.asc -R -o "abc.asc"
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   821  100   821    0     0    698      0  0:00:01  0:00:01 --:--:--   698
Failed to set filetime 1593598063 on outfile: CreateFile failed: GetLastError 123

D:\>curl https://dl.bintray.com/vszakats/generic/curl-7.71.1-win32-mingw.tar.xz.asc -R -o "$T#.asc"
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   821  100   821    0     0    802      0  0:00:01  0:00:01 --:--:--   802
Failed to set filetime 1593598063 on outfile: CreateFile failed: GetLastError 123

D:\>curl https://dl.bintray.com/vszakats/generic/curl-7.71.1-win32-mingw.tar.xz.asc -R -o "TEST.asc"
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   821  100   821    0     0    812      0  0:00:01  0:00:01 --:--:--   812
Failed to set filetime 1593598063 on outfile: CreateFile failed: GetLastError 2

All above file is download, only Failed to set filetime.

Use old version on XP without this problem.

I expected the following

Use this:
https://sslsites.de/paehl.com/open_source/?CURL_7.71.0
and this:
https://skanthak.homepage.t-online.de/curl.html

build no this problem.

curl/libcurl version

[curl -V output]

curl 7.71.1 (x86_64-pc-win32) libcurl/7.71.1 OpenSSL/1.1.1g (Schannel) zlib/1.2.11 brotli/1.0.7 WinIDN libssh2/1.9.0 nghttp2/1.41.0
Release-Date: 2020-07-01
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps mqtt pop3 pop3s rtsp scp sftp smb smbs smtp smtps telnet tftp
Features: AsynchDNS HTTP2 HTTPS-proxy IDN IPv6 Kerberos Largefile MultiSSL NTLM SPNEGO SSL SSPI TLS-SRP UnixSockets brotli libz

operating system

Windows 10 Enterprise 2016 LTSB 1607 x64

Activity

  1. jay commented on Jul 12, 2020

    @jay
    Member

    The setfiletime function uses CreateFileA. There were Unicode changes made to the curl tool recently and I suspect that may have something to do with it. Probably the filename is UTF-8 encoded now? @MarcelRaad

    curl/src/tool_filetime.c

    Lines 106 to 129 in 5a1fc8d

    hfile = CreateFileA(filename, FILE_WRITE_ATTRIBUTES,
    (FILE_SHARE_READ | FILE_SHARE_WRITE |
    FILE_SHARE_DELETE),
    NULL, OPEN_EXISTING, 0, NULL);
    if(hfile != INVALID_HANDLE_VALUE) {
    curl_off_t converted = ((curl_off_t)filetime * 10000000) +
    CURL_OFF_T_C(116444736000000000);
    FILETIME ft;
    ft.dwLowDateTime = (DWORD)(converted & 0xFFFFFFFF);
    ft.dwHighDateTime = (DWORD)(converted >> 32);
    if(!SetFileTime(hfile, NULL, &ft, &ft)) {
    fprintf(error_stream,
    "Failed to set filetime %" CURL_FORMAT_CURL_OFF_T
    " on outfile: SetFileTime failed: GetLastError %u\n",
    filetime, (unsigned int)GetLastError());
    }
    CloseHandle(hfile);
    }
    else {
    fprintf(error_stream,
    "Failed to set filetime %" CURL_FORMAT_CURL_OFF_T
    " on outfile: CreateFile failed: GetLastError %u\n",
    filetime, (unsigned int)GetLastError());
    }

  2. self-assigned this
    on Jul 23, 2020
  3. MarcelRaad commented on Jul 24, 2020

    @MarcelRaad
    Member

    Thanks for the report, and sorry for noticing it so late! Should be fixed with #5718.

    Now I get:

    C:\curl\build\Win64\VC15\LIB Debug - DLL Windows SSPI - DLL WinIDN>.\curld.exe https://dl.bintray.com/vszakats/generic/curl-7.71.1-win32-mingw.tar.xz.asc -R -o 校验.asc
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100   821  100   821    0     0   4367      0 --:--:-- --:--:-- --:--:--  4413
    

    and a file named 校验.asc.

  4. tec1987 commented on Jul 27, 2020

    @tec1987
    Author

    Now is work fine.
    Thanks for all.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions