@@ -708,6 +708,59 @@ do_local_cmd(arglist *a)
708
708
#endif
709
709
}
710
710
711
+ static int pipe_counter = 1 ;
712
+ /* create overlapped supported pipe */
713
+ BOOL CreateOverlappedPipe (PHANDLE hReadPipe , PHANDLE hWritePipe , LPSECURITY_ATTRIBUTES sa , DWORD size ) {
714
+ HANDLE read_handle = INVALID_HANDLE_VALUE , write_handle = INVALID_HANDLE_VALUE ;
715
+ char pipe_name [MAX_PATH ];
716
+
717
+ /* create name for named pipe */
718
+ if (-1 == sprintf_s (pipe_name , MAX_PATH , "\\\\.\\Pipe\\W32SCPPipe.%08x.%08x" ,
719
+ GetCurrentProcessId (), pipe_counter ++ )) {
720
+ debug ("pipe - ERROR sprintf_s %d" , errno );
721
+ goto error ;
722
+ }
723
+
724
+ read_handle = CreateNamedPipeA (pipe_name ,
725
+ PIPE_ACCESS_INBOUND | FILE_FLAG_OVERLAPPED ,
726
+ PIPE_TYPE_BYTE | PIPE_WAIT ,
727
+ 1 ,
728
+ 4096 ,
729
+ 4096 ,
730
+ 0 ,
731
+ sa );
732
+ if (read_handle == INVALID_HANDLE_VALUE ) {
733
+ debug ("pipe - CreateNamedPipe() ERROR:%d" , errno );
734
+ goto error ;
735
+ }
736
+
737
+ /* connect to named pipe */
738
+ write_handle = CreateFileA (pipe_name ,
739
+ GENERIC_WRITE ,
740
+ 0 ,
741
+ sa ,
742
+ OPEN_EXISTING ,
743
+ FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED ,
744
+ NULL );
745
+ if (write_handle == INVALID_HANDLE_VALUE ) {
746
+ debug ("pipe - ERROR CreateFile() :%d" , errno );
747
+ goto error ;
748
+ }
749
+
750
+ * hReadPipe = read_handle ;
751
+ * hWritePipe = write_handle ;
752
+ return TRUE;
753
+
754
+ error :
755
+ if (read_handle )
756
+ CloseHandle (read_handle );
757
+ if (write_handle )
758
+ CloseHandle (write_handle );
759
+
760
+ return FALSE;
761
+
762
+ }
763
+
711
764
/*
712
765
* This function executes the given command as the specified user on the
713
766
* given host. This returns < 0 if execution fails, and >= 0 otherwise. This
@@ -814,7 +867,7 @@ do_cmd(char *host, char *remuser, char *cmd, int *fdin, int *fdout)
814
867
sa .lpSecurityDescriptor = NULL ;
815
868
/* command processor output redirected to a nameless pipe */
816
869
817
- rc = CreatePipe ( & hstdout [0 ], & hstdout [1 ], & sa , 0 ) ;
870
+ rc = CreateOverlappedPipe ( & hstdout [0 ], & hstdout [1 ], & sa , 0 ) ;
818
871
/* read from this fd to get data from ssh.exe*/
819
872
820
873
// make scp's pipe read handle not inheritable by ssh
@@ -830,7 +883,7 @@ do_cmd(char *host, char *remuser, char *cmd, int *fdin, int *fdout)
830
883
* fdin = _open_osfhandle ((intptr_t )hstdout [0 ],0 );
831
884
_setmode (* fdin , O_BINARY ); // set this file handle for binary I/O
832
885
833
- rc = CreatePipe ( & hstdin [0 ], & hstdin [1 ], & sa , 0 ) ;
886
+ rc = CreateOverlappedPipe ( & hstdin [0 ], & hstdin [1 ], & sa , 0 ) ;
834
887
/* write to this fd to get data into ssh.exe*/
835
888
836
889
// make scp's pipe write handle not inheritable by ssh
@@ -1033,11 +1086,7 @@ int pflag, iamremote, iamrecursive, targetshouldbedirectory;
1033
1086
char cmd [CMDNEEDS ]; /* must hold "rcp -r -p -d\0" */
1034
1087
1035
1088
int response (void );
1036
- #ifdef WIN32_FIXME
1037
- void rsource (char * , struct _stati64 * );
1038
- #else
1039
1089
void rsource (char * , struct stat * );
1040
- #endif
1041
1090
1042
1091
void sink (int , char * []);
1043
1092
void source (int , char * []);
@@ -1439,7 +1488,7 @@ tolocal(int argc, char **argv)
1439
1488
void
1440
1489
source (int argc , char * argv [])
1441
1490
{
1442
- struct _stati64 stb ;
1491
+ struct stat stb ;
1443
1492
static BUF buffer ;
1444
1493
BUF * bp ;
1445
1494
off_t i ;
@@ -1520,7 +1569,7 @@ source(int argc, char *argv[])
1520
1569
1521
1570
if (_sopen_s (& fd , name , O_RDONLY | O_BINARY , _SH_DENYNO , 0 ) != 0 ) {
1522
1571
// in NT, we have to check if it is a directory
1523
- if (_stati64 (name , & stb ) >= 0 ) {
1572
+ if (stat (name , & stb ) >= 0 ) {
1524
1573
goto switchpoint ;
1525
1574
}
1526
1575
else
@@ -1692,7 +1741,7 @@ next: if (fd != -1) (void)_close(fd);
1692
1741
free (filenames [ii ]);
1693
1742
}
1694
1743
1695
- void rsource (char * name , struct _stati64 * statp )
1744
+ void rsource (char * name , struct stat * statp )
1696
1745
{
1697
1746
SCPDIR * dirp ;
1698
1747
struct scp_dirent * dp ;
@@ -1754,7 +1803,7 @@ void sink(int argc, char *argv[])
1754
1803
{
1755
1804
// DWORD dwread;
1756
1805
static BUF buffer ;
1757
- struct _stati64 stb ;
1806
+ struct stat stb ;
1758
1807
enum { YES , NO , DISPLAYED } wrerr ;
1759
1808
BUF * bp ;
1760
1809
size_t i , j , size ;
@@ -1812,7 +1861,7 @@ void sink(int argc, char *argv[])
1812
1861
1813
1862
(void )_write (remout , "" , 1 );
1814
1863
1815
- if (_stati64 (targ , & stb ) == 0 && S_ISDIR (stb .st_mode ))
1864
+ if (stat (targ , & stb ) == 0 && S_ISDIR (stb .st_mode ))
1816
1865
targisdir = 1 ;
1817
1866
1818
1867
for (first = 1 ;; first = 0 ) {
@@ -1912,7 +1961,7 @@ void sink(int argc, char *argv[])
1912
1961
np = namebuf ;
1913
1962
} else
1914
1963
np = targ ;
1915
- exists = _stati64 (np , & stb ) == 0 ;
1964
+ exists = stat (np , & stb ) == 0 ;
1916
1965
if (buf [0 ] == 'D' ) {
1917
1966
int mod_flag = pflag ;
1918
1967
if (exists ) {
@@ -2807,9 +2856,9 @@ char *win32colon(char *cp)
2807
2856
2808
2857
void verifydir (char * cp )
2809
2858
{
2810
- struct _stati64 stb ;
2859
+ struct stat stb ;
2811
2860
2812
- if (!_stati64 (cp , & stb )) {
2861
+ if (!stat (cp , & stb )) {
2813
2862
if (S_ISDIR (stb .st_mode ))
2814
2863
return ;
2815
2864
errno = ENOTDIR ;
0 commit comments