Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
tec1987 opened this issue Jul 7, 2020 · 3 comments
Closed

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

tec1987 opened this issue Jul 7, 2020 · 3 comments
Assignees

Comments

@tec1987
Copy link

@tec1987 tec1987 commented Jul 7, 2020

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

@jay
Copy link
Member

@jay jay commented Jul 12, 2020

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());
}

@MarcelRaad MarcelRaad self-assigned this Jul 23, 2020
MarcelRaad added a commit to MarcelRaad/curl that referenced this issue Jul 23, 2020
Except where the results are only used for character output or with
hardcoded string literals.

Fixes curl#5658
Fixes curl#5712
Closes
MarcelRaad added a commit to MarcelRaad/curl that referenced this issue Jul 24, 2020
Except where the results are only used for character output or with
hardcoded string literals.

Fixes curl#5658
Fixes curl#5712
Closes
MarcelRaad added a commit to MarcelRaad/curl that referenced this issue Jul 24, 2020
Except where the results are only used for character output.

Fixes curl#5658
Fixes curl#5712
Closes
MarcelRaad added a commit to MarcelRaad/curl that referenced this issue Jul 24, 2020
Except where the results are only used for character output.

Fixes curl#5658
Fixes curl#5712
Closes curl#5718
@MarcelRaad
Copy link
Member

@MarcelRaad MarcelRaad commented Jul 24, 2020

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.

MarcelRaad added a commit to MarcelRaad/curl that referenced this issue Jul 24, 2020
Except where the results are only used for character output.

Fixes curl#5658
Fixes curl#5712
Closes curl#5718
MarcelRaad added a commit to MarcelRaad/curl that referenced this issue Jul 26, 2020
Except where the results are only used for character output.

Fixes curl#5658
Fixes curl#5712
Closes curl#5718
@tec1987
Copy link
Author

@tec1987 tec1987 commented Jul 27, 2020

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
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

4 participants
You can’t perform that action at this time.