@@ -2051,9 +2051,9 @@ int wolfSSH_SFTP_RecvOpen(WOLFSSH* ssh, int reqId, byte* data, word32 maxSz)
20512051 WS_SFTP_FILEATRB fileAtr ;
20522052 WMEMSET (& fileAtr , 0 , sizeof (fileAtr ));
20532053 if (SFTP_GetAttributes (ssh -> fs ,
2054- dir , & fileAtr , 1 , ssh -> ctx -> heap ) == WS_SUCCESS ) {
2055- if ((fileAtr .per & FILEATRB_PER_MASK_TYPE ) != FILEATRB_PER_FILE ) {
2056- WLOG ( WS_LOG_SFTP , "Not a file" );
2054+ dir , & fileAtr , 0 , ssh -> ctx -> heap ) == WS_SUCCESS ) {
2055+ if ((fileAtr .per & FILEATRB_PER_MASK_TYPE )
2056+ != FILEATRB_PER_FILE ) {
20572057 ssh -> error = WS_SFTP_NOT_FILE_E ;
20582058
20592059 res = naf ;
@@ -2607,7 +2607,15 @@ static int SFTP_CreateLongName(WS_SFTPNAME* name)
26072607 word32 tmp = atr -> per ;
26082608
26092609 i = 0 ;
2610- perm [i ++ ] = (tmp & 0x4000 )?'d' :'-' ;
2610+ if (tmp & FILEATRB_PER_DIR ) {
2611+ perm [i ++ ] = 'd' ;
2612+ }
2613+ else if (tmp & FILEATRB_PER_LINK ) {
2614+ perm [i ++ ] = 'l' ;
2615+ }
2616+ else {
2617+ perm [i ++ ] = '-' ;
2618+ }
26112619 perm [i ++ ] = (tmp & 0x100 )?'r' :'-' ;
26122620 perm [i ++ ] = (tmp & 0x080 )?'w' :'-' ;
26132621 perm [i ++ ] = (tmp & 0x040 )?'x' :'-' ;
@@ -3153,7 +3161,7 @@ static int wolfSSH_SFTPNAME_readdir(WOLFSSH* ssh, WDIR* dir, WS_SFTPNAME* out,
31533161 return WS_FATAL_ERROR ;
31543162 }
31553163
3156- if (SFTP_GetAttributes (ssh -> fs , s , & out -> atrb , 0 , ssh -> ctx -> heap )
3164+ if (SFTP_GetAttributes (ssh -> fs , s , & out -> atrb , 1 , ssh -> ctx -> heap )
31573165 != WS_SUCCESS ) {
31583166 WLOG (WS_LOG_SFTP , "Unable to get attribute values for %s" ,
31593167 out -> fName );
@@ -8592,8 +8600,8 @@ int wolfSSH_SFTP_Get(WOLFSSH* ssh, char* from,
85928600 NO_BREAK ;
85938601
85948602 case STATE_GET_LSTAT :
8595- WLOG (WS_LOG_SFTP , "SFTP GET STATE: LSTAT " );
8596- ret = wolfSSH_SFTP_LSTAT (ssh , from , & state -> attrib );
8603+ WLOG (WS_LOG_SFTP , "SFTP GET STATE: STAT " );
8604+ ret = wolfSSH_SFTP_STAT (ssh , from , & state -> attrib );
85978605 if (ret != WS_SUCCESS ) {
85988606 if (ssh -> error == WS_WANT_READ ||
85998607 ssh -> error == WS_WANT_WRITE )
@@ -8603,7 +8611,9 @@ int wolfSSH_SFTP_Get(WOLFSSH* ssh, char* from,
86038611 continue ;
86048612 }
86058613 if ((state -> attrib .per & FILEATRB_PER_MASK_TYPE )
8606- != FILEATRB_PER_FILE ) {
8614+ != FILEATRB_PER_FILE
8615+ && (state -> attrib .per & FILEATRB_PER_MASK_TYPE )
8616+ != FILEATRB_PER_LINK ) {
86078617 WLOG (WS_LOG_SFTP , "Not a file" );
86088618 ssh -> error = WS_SFTP_NOT_FILE_E ;
86098619 ret = WS_FATAL_ERROR ;
0 commit comments