Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
e8eaee4f
Commit
e8eaee4f
authored
Oct 26, 2007
by
Hans Leidekker
Committed by
Alexandre Julliard
Oct 29, 2007
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wininet: Always close the data connection before receiving a server response.
parent
e55531d6
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
45 deletions
+33
-45
ftp.c
dlls/wininet/ftp.c
+8
-11
ftp.c
dlls/wininet/tests/ftp.c
+25
-34
No files found.
dlls/wininet/ftp.c
View file @
e8eaee4f
...
@@ -1365,15 +1365,16 @@ BOOL WINAPI FTP_FtpGetFileW(LPWININETFTPSESSIONW lpwfs, LPCWSTR lpszRemoteFile,
...
@@ -1365,15 +1365,16 @@ BOOL WINAPI FTP_FtpGetFileW(LPWININETFTPSESSIONW lpwfs, LPCWSTR lpszRemoteFile,
/* Receive data */
/* Receive data */
FTP_RetrieveFileData
(
lpwfs
,
nDataSocket
,
hFile
);
FTP_RetrieveFileData
(
lpwfs
,
nDataSocket
,
hFile
);
closesocket
(
nDataSocket
);
nResCode
=
FTP_ReceiveResponse
(
lpwfs
,
dwContext
);
nResCode
=
FTP_ReceiveResponse
(
lpwfs
,
dwContext
);
if
(
nResCode
)
if
(
nResCode
)
{
{
if
(
nResCode
==
226
)
if
(
nResCode
==
226
)
bSuccess
=
TRUE
;
bSuccess
=
TRUE
;
else
else
FTP_SetResponseError
(
nResCode
);
FTP_SetResponseError
(
nResCode
);
}
}
closesocket
(
nDataSocket
);
}
}
}
}
...
@@ -3008,7 +3009,7 @@ static void FTP_CloseFindNextHandle(LPWININETHANDLEHEADER hdr)
...
@@ -3008,7 +3009,7 @@ static void FTP_CloseFindNextHandle(LPWININETHANDLEHEADER hdr)
* FTP_CloseFileTransferHandle (internal)
* FTP_CloseFileTransferHandle (internal)
*
*
* Closes the file transfer handle. This also 'cleans' the data queue of
* Closes the file transfer handle. This also 'cleans' the data queue of
* the 'transfer co
n
plete' message (this is a bit of a hack though :-/ )
* the 'transfer co
m
plete' message (this is a bit of a hack though :-/ )
*
*
*/
*/
static
void
FTP_CloseFileTransferHandle
(
LPWININETHANDLEHEADER
hdr
)
static
void
FTP_CloseFileTransferHandle
(
LPWININETHANDLEHEADER
hdr
)
...
@@ -3022,18 +3023,14 @@ static void FTP_CloseFileTransferHandle(LPWININETHANDLEHEADER hdr)
...
@@ -3022,18 +3023,14 @@ static void FTP_CloseFileTransferHandle(LPWININETHANDLEHEADER hdr)
WININET_Release
(
&
lpwh
->
lpFtpSession
->
hdr
);
WININET_Release
(
&
lpwh
->
lpFtpSession
->
hdr
);
if
(
!
lpwh
->
session_deleted
)
if
(
!
lpwh
->
session_deleted
)
lpwfs
->
download_in_progress
=
NULL
;
lpwfs
->
download_in_progress
=
NULL
;
/* This just serves to flush the control socket of any spurrious lines written
to it (like '226 Transfer complete.').
Wonder what to do if the server sends us an error code though...
*/
nResCode
=
FTP_ReceiveResponse
(
lpwfs
,
lpwfs
->
hdr
.
dwContext
);
if
(
lpwh
->
nDataSocket
!=
-
1
)
if
(
lpwh
->
nDataSocket
!=
-
1
)
closesocket
(
lpwh
->
nDataSocket
);
closesocket
(
lpwh
->
nDataSocket
);
nResCode
=
FTP_ReceiveResponse
(
lpwfs
,
lpwfs
->
hdr
.
dwContext
);
if
(
nResCode
>
0
&&
nResCode
!=
226
)
WARN
(
"server reports failed transfer
\n
"
);
HeapFree
(
GetProcessHeap
(),
0
,
lpwh
);
HeapFree
(
GetProcessHeap
(),
0
,
lpwh
);
}
}
...
...
dlls/wininet/tests/ftp.c
View file @
e8eaee4f
...
@@ -301,16 +301,12 @@ static void test_getfile(void)
...
@@ -301,16 +301,12 @@ static void test_getfile(void)
/* Zero attributes */
/* Zero attributes */
SetLastError
(
0xdeadbeef
);
SetLastError
(
0xdeadbeef
);
bRet
=
FtpGetFileA
(
hFtp
,
"welcome.msg"
,
"should_be_non_existing_deadbeef"
,
FALSE
,
0
,
FTP_TRANSFER_TYPE_UNKNOWN
,
0
);
bRet
=
FtpGetFileA
(
hFtp
,
"welcome.msg"
,
"should_be_existing_non_deadbeef"
,
FALSE
,
0
,
FTP_TRANSFER_TYPE_UNKNOWN
,
0
);
ok
(
bRet
==
FALSE
,
"Expected FtpGetFileA to fail
\n
"
);
ok
(
bRet
==
TRUE
,
"Expected FtpGetFileA to succeed
\n
"
);
todo_wine
ok
(
GetLastError
()
==
ERROR_SUCCESS
,
"Expected ERROR_SUCCESS, got %d
\n
"
,
GetLastError
());
{
ok
(
GetFileAttributesA
(
"should_be_existing_non_deadbeef"
)
!=
INVALID_FILE_ATTRIBUTES
,
ok
(
GetLastError
()
==
ERROR_INTERNET_EXTENDED_ERROR
,
"Local file should have been created
\n
"
);
"Expected ERROR_INTERNET_EXTENDED_ERROR, got %d
\n
"
,
GetLastError
());
DeleteFileA
(
"should_be_existing_non_deadbeef"
);
ok
(
GetFileAttributesA
(
"should_be_non_existing_deadbeef"
)
==
INVALID_FILE_ATTRIBUTES
,
"Local file should not have been created
\n
"
);
}
DeleteFileA
(
"should_be_non_existing_deadbeef"
);
/* Illegal condition flags */
/* Illegal condition flags */
SetLastError
(
0xdeadbeef
);
SetLastError
(
0xdeadbeef
);
...
@@ -326,12 +322,14 @@ static void test_getfile(void)
...
@@ -326,12 +322,14 @@ static void test_getfile(void)
SetLastError
(
0xdeadbeef
);
SetLastError
(
0xdeadbeef
);
bRet
=
FtpGetFileA
(
hFtp
,
"should_be_non_existing_deadbeef"
,
"should_also_be_non_existing_deadbeef"
,
FALSE
,
FILE_ATTRIBUTE_NORMAL
,
FTP_TRANSFER_TYPE_UNKNOWN
,
0
);
bRet
=
FtpGetFileA
(
hFtp
,
"should_be_non_existing_deadbeef"
,
"should_also_be_non_existing_deadbeef"
,
FALSE
,
FILE_ATTRIBUTE_NORMAL
,
FTP_TRANSFER_TYPE_UNKNOWN
,
0
);
ok
(
bRet
==
FALSE
,
"Expected FtpGetFileA to fail
\n
"
);
ok
(
bRet
==
FALSE
,
"Expected FtpGetFileA to fail
\n
"
);
todo_wine
{
ok
(
GetLastError
()
==
ERROR_INTERNET_EXTENDED_ERROR
,
ok
(
GetLastError
()
==
ERROR_INTERNET_EXTENDED_ERROR
,
"Expected ERROR_INTERNET_EXTENDED_ERROR, got %d
\n
"
,
GetLastError
());
"Expected ERROR_INTERNET_EXTENDED_ERROR, got %d
\n
"
,
GetLastError
());
/* Currently Wine always creates the local file (even on failure) which is not correct, hence the test */
/* Currently Wine always creates the local file (even on failure) which is not correct, hence the test */
todo_wine
ok
(
GetFileAttributesA
(
"should_also_be_non_existing_deadbeef"
)
==
INVALID_FILE_ATTRIBUTES
,
ok
(
GetFileAttributesA
(
"should_also_be_non_existing_deadbeef"
)
==
INVALID_FILE_ATTRIBUTES
,
"Local file should not have been created
\n
"
);
"Local file should not have been created
\n
"
);
}
DeleteFileA
(
"should_also_be_non_existing_deadbeef"
);
DeleteFileA
(
"should_also_be_non_existing_deadbeef"
);
/* Same call as the previous but now the local file does exists. Windows just removes the file if the call fails
/* Same call as the previous but now the local file does exists. Windows just removes the file if the call fails
...
@@ -346,32 +344,30 @@ static void test_getfile(void)
...
@@ -346,32 +344,30 @@ static void test_getfile(void)
SetLastError
(
0xdeadbeef
);
SetLastError
(
0xdeadbeef
);
bRet
=
FtpGetFileA
(
hFtp
,
"should_be_non_existing_deadbeef"
,
"should_also_be_non_existing_deadbeef"
,
FALSE
,
FILE_ATTRIBUTE_NORMAL
,
FTP_TRANSFER_TYPE_UNKNOWN
,
0
);
bRet
=
FtpGetFileA
(
hFtp
,
"should_be_non_existing_deadbeef"
,
"should_also_be_non_existing_deadbeef"
,
FALSE
,
FILE_ATTRIBUTE_NORMAL
,
FTP_TRANSFER_TYPE_UNKNOWN
,
0
);
ok
(
bRet
==
FALSE
,
"Expected FtpGetFileA to fail
\n
"
);
ok
(
bRet
==
FALSE
,
"Expected FtpGetFileA to fail
\n
"
);
todo_wine
{
ok
(
GetLastError
()
==
ERROR_INTERNET_EXTENDED_ERROR
,
ok
(
GetLastError
()
==
ERROR_INTERNET_EXTENDED_ERROR
,
"Expected ERROR_INTERNET_EXTENDED_ERROR, got %d
\n
"
,
GetLastError
());
"Expected ERROR_INTERNET_EXTENDED_ERROR, got %d
\n
"
,
GetLastError
());
/* Currently Wine always creates the local file (even on failure) which is not correct, hence the test */
/* Currently Wine always creates the local file (even on failure) which is not correct, hence the test */
todo_wine
ok
(
GetFileAttributesA
(
"should_also_be_non_existing_deadbeef"
)
==
INVALID_FILE_ATTRIBUTES
,
ok
(
GetFileAttributesA
(
"should_also_be_non_existing_deadbeef"
)
==
INVALID_FILE_ATTRIBUTES
,
"Local file should not have been created
\n
"
);
"Local file should not have been created
\n
"
);
}
DeleteFileA
(
"should_also_be_non_existing_deadbeef"
);
DeleteFileA
(
"should_also_be_non_existing_deadbeef"
);
/* This one should
fail
*/
/* This one should
succeed
*/
SetLastError
(
0xdeadbeef
);
SetLastError
(
0xdeadbeef
);
bRet
=
FtpGetFileA
(
hFtp
,
"welcome.msg"
,
"should_be_non_existing_deadbeef"
,
FALSE
,
FILE_ATTRIBUTE_NORMAL
,
FTP_TRANSFER_TYPE_UNKNOWN
,
0
);
bRet
=
FtpGetFileA
(
hFtp
,
"welcome.msg"
,
"should_be_existing_non_deadbeef"
,
FALSE
,
FILE_ATTRIBUTE_NORMAL
,
FTP_TRANSFER_TYPE_UNKNOWN
,
0
);
ok
(
bRet
==
FALSE
,
"Expected FtpGetFileA to fail
\n
"
);
ok
(
bRet
==
TRUE
,
"Expected FtpGetFileA to fail
\n
"
);
ok
(
GetLastError
()
==
ERROR_INTERNET_EXTENDED_ERROR
,
ok
(
GetLastError
()
==
ERROR_SUCCESS
,
"Expected ERROR_SUCCESS, got %d
\n
"
,
GetLastError
());
"Expected ERROR_INTERNET_EXTENDED_ERROR, got %d
\n
"
,
GetLastError
());
if
(
GetFileAttributesA
(
"should_be_
non_existing
_deadbeef"
)
!=
INVALID_FILE_ATTRIBUTES
)
if
(
GetFileAttributesA
(
"should_be_
existing_non
_deadbeef"
)
!=
INVALID_FILE_ATTRIBUTES
)
{
{
/* Should succeed as fFailIfExists is set to FALSE (meaning don't fail if local file exists) */
/* Should succeed as fFailIfExists is set to FALSE (meaning don't fail if local file exists) */
SetLastError
(
0xdeadbeef
);
SetLastError
(
0xdeadbeef
);
bRet
=
FtpGetFileA
(
hFtp
,
"welcome.msg"
,
"should_be_non_existing_deadbeef"
,
FALSE
,
FILE_ATTRIBUTE_NORMAL
,
FTP_TRANSFER_TYPE_UNKNOWN
,
0
);
bRet
=
FtpGetFileA
(
hFtp
,
"welcome.msg"
,
"should_be_non_existing_deadbeef"
,
FALSE
,
FILE_ATTRIBUTE_NORMAL
,
FTP_TRANSFER_TYPE_UNKNOWN
,
0
);
todo_wine
{
ok
(
bRet
==
TRUE
,
"Expected FtpGetFileA to succeed
\n
"
);
ok
(
bRet
==
TRUE
,
"Expected FtpGetFileA to succeed
\n
"
);
ok
(
GetLastError
()
==
ERROR_SUCCESS
,
ok
(
GetLastError
()
==
ERROR_SUCCESS
,
"Expected ERROR_SUCCESS, got %d
\n
"
,
GetLastError
());
"Expected ERROR_SUCCESS, got %d
\n
"
,
GetLastError
());
}
/* Should fail as fFailIfExists is set to TRUE */
/* Should fail as fFailIfExists is set to TRUE */
SetLastError
(
0xdeadbeef
);
SetLastError
(
0xdeadbeef
);
...
@@ -387,7 +383,7 @@ static void test_getfile(void)
...
@@ -387,7 +383,7 @@ static void test_getfile(void)
ok
(
GetLastError
()
==
ERROR_FILE_EXISTS
,
ok
(
GetLastError
()
==
ERROR_FILE_EXISTS
,
"Expected ERROR_FILE_EXISTS, got %d
\n
"
,
GetLastError
());
"Expected ERROR_FILE_EXISTS, got %d
\n
"
,
GetLastError
());
DeleteFileA
(
"should_be_
non_existing
_deadbeef"
);
DeleteFileA
(
"should_be_
existing_non
_deadbeef"
);
}
}
InternetCloseHandle
(
hFtp
);
InternetCloseHandle
(
hFtp
);
...
@@ -478,13 +474,8 @@ static void test_openfile(void)
...
@@ -478,13 +474,8 @@ static void test_openfile(void)
SetLastError
(
0xdeadbeef
);
SetLastError
(
0xdeadbeef
);
hOpenFile
=
FtpOpenFileA
(
hFtp
,
"welcome.msg"
,
GENERIC_READ
,
FTP_TRANSFER_TYPE_ASCII
,
0
);
hOpenFile
=
FtpOpenFileA
(
hFtp
,
"welcome.msg"
,
GENERIC_READ
,
FTP_TRANSFER_TYPE_ASCII
,
0
);
todo_wine
ok
(
hOpenFile
!=
NULL
,
"Expected FtpOpenFileA to succeed
\n
"
);
{
ok
(
GetLastError
()
==
ERROR_SUCCESS
,
"Expected ERROR_SUCCESS, got %u
\n
"
,
GetLastError
());
ok
(
hOpenFile
==
NULL
,
"Expected FtpOpenFileA to fail
\n
"
);
/* For some strange/unknown reason, win98 returns ERROR_FILE_NOT_FOUND */
ok
(
GetLastError
()
==
ERROR_INTERNET_EXTENDED_ERROR
||
GetLastError
()
==
ERROR_FILE_NOT_FOUND
,
"Expected ERROR_INTERNET_EXTENDED_ERROR or ERROR_FILE_NOT_FOUND (win98), got %d
\n
"
,
GetLastError
());
}
if
(
hOpenFile
)
if
(
hOpenFile
)
{
{
...
@@ -840,14 +831,14 @@ static void test_multiple(void)
...
@@ -840,14 +831,14 @@ static void test_multiple(void)
}
}
/* A correct call */
/* A correct call */
bRet
=
FtpGetFileA
(
hFtp
,
"welcome.msg"
,
"should_be_non_existing_deadbeef"
,
FALSE
,
FILE_ATTRIBUTE_NORMAL
,
FTP_TRANSFER_TYPE_UNKNOWN
,
0
);
bRet
=
FtpGetFileA
(
hFtp
,
"welcome.msg"
,
"should_be_existing_non_deadbeef"
,
FALSE
,
FILE_ATTRIBUTE_NORMAL
,
FTP_TRANSFER_TYPE_UNKNOWN
,
0
);
DeleteFileA
(
"should_be_non_existing_deadbeef"
);
ok
(
bRet
,
"Expected FtpGetFileA to succeed
\n
"
);
DeleteFileA
(
"should_be_existing_non_deadbeef"
);
SetLastError
(
0xdeadbeef
);
SetLastError
(
0xdeadbeef
);
hOpenFile
=
FtpOpenFileA
(
hFtp
,
"welcome.msg"
,
GENERIC_READ
,
FTP_TRANSFER_TYPE_ASCII
,
0
);
hOpenFile
=
FtpOpenFileA
(
hFtp
,
"welcome.msg"
,
GENERIC_READ
,
FTP_TRANSFER_TYPE_ASCII
,
0
);
ok
(
hOpenFile
==
NULL
,
"Expected FtpOpenFileA to fail
\n
"
);
ok
(
hOpenFile
!=
NULL
,
"Expected FtpOpenFileA to succeed
\n
"
);
ok
(
GetLastError
()
==
ERROR_INTERNET_EXTENDED_ERROR
||
GetLastError
()
==
ERROR_FILE_NOT_FOUND
,
ok
(
GetLastError
()
==
ERROR_SUCCESS
,
"Expected ERROR_SUCCESS, got %u
\n
"
,
GetLastError
());
"Expected ERROR_INTERNET_EXTENDED_ERROR or ERROR_FILE_NOT_FOUND (win98), got %d
\n
"
,
GetLastError
());
InternetCloseHandle
(
hOpenFile
);
InternetCloseHandle
(
hOpenFile
);
InternetCloseHandle
(
hFtp
);
InternetCloseHandle
(
hFtp
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment