Skip to content

Commit

Permalink
SFTP Symlink
Browse files Browse the repository at this point in the history
1. When trying to get a symlink, treat it as a file.
2. When trying to put a symlink, treat it as a file.
  • Loading branch information
ejohnstown committed Jun 13, 2024
1 parent 524b5c6 commit 4f834ae
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/wolfsftp.c
Original file line number Diff line number Diff line change
Expand Up @@ -2052,8 +2052,10 @@ int wolfSSH_SFTP_RecvOpen(WOLFSSH* ssh, int reqId, byte* data, word32 maxSz)
WMEMSET(&fileAtr, 0, sizeof(fileAtr));
if (SFTP_GetAttributes(ssh->fs,
dir, &fileAtr, 1, ssh->ctx->heap) == WS_SUCCESS) {
if ((fileAtr.per & FILEATRB_PER_MASK_TYPE) != FILEATRB_PER_FILE) {
WLOG(WS_LOG_SFTP, "Not a file");
if ((fileAtr.per & FILEATRB_PER_MASK_TYPE)
!= FILEATRB_PER_FILE
&& (fileAtr.per & FILEATRB_PER_MASK_TYPE)
!= FILEATRB_PER_LINK) {
ssh->error = WS_SFTP_NOT_FILE_E;

res = naf;
Expand Down Expand Up @@ -8597,7 +8599,9 @@ int wolfSSH_SFTP_Get(WOLFSSH* ssh, char* from,
continue;
}
if ((state->attrib.per & FILEATRB_PER_MASK_TYPE)
!= FILEATRB_PER_FILE) {
!= FILEATRB_PER_FILE
&& (state->attrib.per & FILEATRB_PER_MASK_TYPE)
!= FILEATRB_PER_LINK) {
WLOG(WS_LOG_SFTP, "Not a file");
ssh->error = WS_SFTP_NOT_FILE_E;
ret = WS_FATAL_ERROR;
Expand Down Expand Up @@ -8844,7 +8848,9 @@ int wolfSSH_SFTP_Put(WOLFSSH* ssh, char* from, char* to, byte resume,
from, &fileAtr, 1, ssh->ctx->heap)
== WS_SUCCESS) {
if ((fileAtr.per & FILEATRB_PER_MASK_TYPE)
!= FILEATRB_PER_FILE) {
!= FILEATRB_PER_FILE
&& (fileAtr.per & FILEATRB_PER_MASK_TYPE)
!= FILEATRB_PER_LINK) {
WLOG(WS_LOG_SFTP, "Not a file");
ssh->error = WS_SFTP_NOT_FILE_E;
ret = WS_FATAL_ERROR;
Expand Down
1 change: 1 addition & 0 deletions wolfssh/wolfsftp.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ struct WS_SFTP_FILEATRB_EX {

#define FILEATRB_PER_MASK_TYPE 0770000
#define FILEATRB_PER_FILE 0100000
#define FILEATRB_PER_LINK 0120000
#define FILEATRB_PER_DEV_CHAR 0020000
#define FILEATRB_PER_DIR 0040000
#define FILEATRB_PER_DEV_BLOCK 0060000
Expand Down

0 comments on commit 4f834ae

Please sign in to comment.