From a28e2a86069d7c1f93d16b707be4b89fcec59879 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Pierre=20Andr=C3=A9?= Date: Tue, 6 Aug 2013 11:39:13 +0200 Subject: [PATCH] Fixed dealing with errors getting the file size from Windows Using SetFilePointer() for compatibility with old Windows implies a specific management of errors.... --- libntfs-3g/win32_io.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libntfs-3g/win32_io.c b/libntfs-3g/win32_io.c index 6195f8a5..b7e1cc92 100644 --- a/libntfs-3g/win32_io.c +++ b/libntfs-3g/win32_io.c @@ -592,9 +592,11 @@ static s64 ntfs_device_win32_getsize(HANDLE handle) { LONG loword, hiword; + SetLastError(NO_ERROR); hiword = 0; loword = SetFilePointer(handle, 0, &hiword, 2); - if (loword == INVALID_FILE_SIZE) { + if ((loword == INVALID_SET_FILE_POINTER) + && (GetLastError() != NO_ERROR)) { errno = ntfs_w32error_to_errno(GetLastError()); ntfs_log_trace("Couldn't get file size.\n"); return -1;