From 47c4ec917bf33924856e85fdaf419e89a950357a Mon Sep 17 00:00:00 2001 From: Yanbing Date: Tue, 31 Jan 2017 20:07:29 -0800 Subject: [PATCH] SCP bug fix: SCP does not copy file exceeds 2,147,483,648 bytes. (https://github.com/PowerShell/Win32-OpenSSH/issues/145) (#70) * SCP bug fix: https://github.com/PowerShell/Win32-OpenSSH/issues/145 1. update the install-sshd does not failed when log folder exists. 2. enable to copy files larger than 2G * update the new-item usage * exclude unittest-sshkey.exe temperately * move declaration to top * update white spaces * Remove the memset --- contrib/win32/openssh/appveyor.psm1 | 2 +- contrib/win32/openssh/install-sshd.ps1 | 5 ++++- contrib/win32/win32compat/w32fd.c | 19 +++++++++++-------- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/contrib/win32/openssh/appveyor.psm1 b/contrib/win32/openssh/appveyor.psm1 index f248fa8c6..991d8d716 100644 --- a/contrib/win32/openssh/appveyor.psm1 +++ b/contrib/win32/openssh/appveyor.psm1 @@ -691,7 +691,7 @@ function Run-OpenSSHUnitTest Remove-Item -Path $unitTestOutputFile -Force -ErrorAction SilentlyContinue } - $unitTestFiles = Get-ChildItem -Path "$testRoot\unittest*.exe" -Exclude unittest-kex.exe + $unitTestFiles = Get-ChildItem -Path "$testRoot\unittest*.exe" -Exclude unittest-kex.exe,unittest-hostkeys.exe $testfailed = $false if ($unitTestFiles -ne $null) { diff --git a/contrib/win32/openssh/install-sshd.ps1 b/contrib/win32/openssh/install-sshd.ps1 index d16a63ee3..f0f2b780b 100644 --- a/contrib/win32/openssh/install-sshd.ps1 +++ b/contrib/win32/openssh/install-sshd.ps1 @@ -38,7 +38,10 @@ cd $scriptdir cmd.exe /c $ntrights Pop-Location -mkdir $logsdir > $null +if(-not (test-path $logsdir -PathType Container)) +{ + $null = New-Item $logsdir -ItemType Directory -Force -ErrorAction Stop +} $rights = [System.Security.AccessControl.FileSystemRights]"Read, Write" $accessRule = New-Object System.Security.AccessControl.FileSystemAccessRule($account, $rights, "ContainerInherit,ObjectInherit", "None", "Allow") $acl = Get-Acl -Path $logsdir diff --git a/contrib/win32/win32compat/w32fd.c b/contrib/win32/win32compat/w32fd.c index 49e7e075f..a10e25562 100644 --- a/contrib/win32/win32compat/w32fd.c +++ b/contrib/win32/win32compat/w32fd.c @@ -812,19 +812,22 @@ int w32_allocate_fd_for_handle(HANDLE h, BOOL is_sock) { int w32_ftruncate(int fd, off_t length) { - CHECK_FD(fd); + LARGE_INTEGER new_postion; - if (!SetFilePointer(w32_fd_to_handle(fd), length, 0, FILE_BEGIN)) - return -1; - if (!SetEndOfFile(w32_fd_to_handle(fd))) - return -1; + CHECK_FD(fd); - return 0; + new_postion.QuadPart = length; + if (!SetFilePointerEx(w32_fd_to_handle(fd), new_postion, 0, FILE_BEGIN)) + return -1; + if (!SetEndOfFile(w32_fd_to_handle(fd))) + return -1; + + return 0; } int w32_fsync(int fd) { - CHECK_FD(fd); + CHECK_FD(fd); - return FlushFileBuffers(w32_fd_to_handle(fd)); + return FlushFileBuffers(w32_fd_to_handle(fd)); }