Skip to content

Commit 09cbe92

Browse files
yosuke-wolfsslejohnstown
authored andcommitted
Fix ssh->fs reference in Nucleus/Harmony SFTP_GetAttributes helpers
1 parent 9011f55 commit 09cbe92

1 file changed

Lines changed: 11 additions & 8 deletions

File tree

src/wolfsftp.c

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4960,13 +4960,14 @@ static int SFTP_GetAttributes(void* fs, const char* fileName,
49604960
int ret;
49614961

49624962
WOLFSSH_UNUSED(heap);
4963+
/* WSTAT/WLSTAT discard the fs handle on Nucleus, so fs stays unused. */
49634964
WOLFSSH_UNUSED(fs);
49644965

49654966
if (noFollow) {
4966-
ret = WLSTAT(ssh->fs, fileName, &stats);
4967+
ret = WLSTAT(fs, fileName, &stats);
49674968
}
49684969
else {
4969-
ret = WSTAT(ssh->fs, fileName, &stats);
4970+
ret = WSTAT(fs, fileName, &stats);
49704971
}
49714972

49724973
WMEMSET(atr, 0, sizeof(WS_SFTP_FILEATRB));
@@ -5530,12 +5531,16 @@ static int SFTP_GetAttributesStat(WS_SFTP_FILEATRB* atr, WSTAT_T* stats)
55305531
}
55315532

55325533

5533-
static int SFTP_GetAttributesHelper(WS_SFTP_FILEATRB* atr, const char* fName)
5534+
static int SFTP_GetAttributesHelper(void* fs, WS_SFTP_FILEATRB* atr,
5535+
const char* fName)
55345536
{
55355537
WSTAT_T stats;
55365538
SYS_FS_RESULT res;
55375539
char buffer[255];
55385540

5541+
/* WSTAT discards the fs handle on Harmony, so fs stays unused. */
5542+
WOLFSSH_UNUSED(fs);
5543+
55395544
WMEMSET(atr, 0, sizeof(WS_SFTP_FILEATRB));
55405545
WMEMSET(buffer, 0, sizeof(buffer));
55415546
res = SYS_FS_CurrentDriveGet(buffer);
@@ -5554,7 +5559,7 @@ static int SFTP_GetAttributesHelper(WS_SFTP_FILEATRB* atr, const char* fName)
55545559
}
55555560
}
55565561

5557-
if (WSTAT(ssh->fs, fName, &stats) != 0) {
5562+
if (WSTAT(fs, fName, &stats) != 0) {
55585563
WLOG(WS_LOG_SFTP, "Issue with WSTAT call");
55595564
return WS_BAD_FILE_E;
55605565
}
@@ -5571,9 +5576,8 @@ static int SFTP_GetAttributes(void* fs, const char* fileName,
55715576
WS_SFTP_FILEATRB* atr, byte noFollow, void* heap)
55725577
{
55735578
WOLFSSH_UNUSED(heap);
5574-
WOLFSSH_UNUSED(fs);
55755579

5576-
return SFTP_GetAttributesHelper(atr, fileName);
5580+
return SFTP_GetAttributesHelper(fs, atr, fileName);
55775581
}
55785582

55795583

@@ -5587,9 +5591,8 @@ static int SFTP_GetAttributes(void* fs, const char* fileName,
55875591
static int SFTP_GetAttributes_Handle(WOLFSSH* ssh, WFD fd,
55885592
char* name, WS_SFTP_FILEATRB* atr)
55895593
{
5590-
WOLFSSH_UNUSED(ssh);
55915594
WOLFSSH_UNUSED(fd);
5592-
return SFTP_GetAttributesHelper(atr, name);
5595+
return SFTP_GetAttributesHelper(ssh->fs, atr, name);
55935596
}
55945597
#endif /* !NO_WOLFSSH_SERVER */
55955598

0 commit comments

Comments
 (0)