Skip to content

Commit fb1aa6d

Browse files
yosuke-wolfsslejohnstown
authored andcommitted
Fix minor issues and Add test vectors
1 parent 4b948e6 commit fb1aa6d

4 files changed

Lines changed: 25 additions & 19 deletions

File tree

apps/wolfsshd/configuration.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,13 +103,17 @@ static long GetConfigInt(const char* in, int inSz, int isTime, void* heap)
103103
int mult = 1; /* multiplier */
104104
int sz = inSz;
105105

106+
if (in == NULL || inSz <= 0) {
107+
ret = WS_BAD_ARGUMENT;
108+
}
109+
106110
/* check for multipliers */
107-
if (isTime) {
111+
if (ret == 0 && isTime) {
108112
if (in[sz - 1] == 'm') {
109113
sz--;
110114
mult = 60;
111115
}
112-
if (in[sz - 1] == 'h') {
116+
else if (in[sz - 1] == 'h') {
113117
sz--;
114118
mult = 60*60;
115119
}

apps/wolfsshd/test/test_configuration.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,8 @@ static int test_ParseConfigLine(void)
229229
{"Valid login grace time minutes", "LoginGraceTime 1m", 0},
230230
{"Valid login grace time hours", "LoginGraceTime 1h", 0},
231231
{"Invalid login grace time", "LoginGraceTime wolfsshd", 1},
232+
{"Bare multiplier m (no digit)", "LoginGraceTime m", 1},
233+
{"Bare multiplier h (no digit)", "LoginGraceTime h", 1},
232234

233235
/* Permit empty password tests. */
234236
{"Permit empty password no", "PermitEmptyPasswords no", 0},

examples/scpclient/scpclient.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -296,9 +296,6 @@ THREAD_RETURN WOLFSSH_THREAD scp_client(void* args)
296296
if (ret != WS_SUCCESS)
297297
err_sys("Couldn't set the session's socket.");
298298

299-
if (ret != WS_SUCCESS)
300-
err_sys("Couldn't set the channel type.");
301-
302299
do {
303300
if (dir == copyFromSrv)
304301
ret = wolfSSH_SCP_from(ssh, path1, path2);

src/wolfsftp.c

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1835,12 +1835,11 @@ int wolfSSH_SFTP_RecvRMDIR(WOLFSSH* ssh, int reqId, byte* data, word32 maxSz)
18351835
*/
18361836
int wolfSSH_SFTP_RecvMKDIR(WOLFSSH* ssh, int reqId, byte* data, word32 maxSz)
18371837
{
1838-
word32 attrFlags;
1838+
WS_SFTP_FILEATRB atr;
18391839
word32 strSz;
18401840
const byte* str;
18411841
int ret;
18421842
char dir[WOLFSSH_MAX_FILENAME];
1843-
word32 mode = 0;
18441843
word32 idx = 0;
18451844
byte* out;
18461845
word32 outSz = 0;
@@ -1866,22 +1865,26 @@ int wolfSSH_SFTP_RecvMKDIR(WOLFSSH* ssh, int reqId, byte* data, word32 maxSz)
18661865
return ret;
18671866
}
18681867

1869-
if (GetUint32(&attrFlags, data, maxSz, &idx) != WS_SUCCESS) {
1868+
if (SFTP_ParseAttributes_buffer(ssh, &atr, data, &idx, maxSz)
1869+
!= WS_SUCCESS) {
18701870
return WS_BUFFER_E;
18711871
}
1872-
if (attrFlags != WOLFSSH_FILEATRB_PERM) {
1873-
WLOG(WS_LOG_SFTP, "Only permission attribute supported");
1874-
WLOG(WS_LOG_SFTP, "Skipping over attribute and using default");
1875-
mode = 040755;
1876-
}
1877-
else {
1878-
if (GetUint32(&mode, data, maxSz, &idx) != WS_SUCCESS) {
1879-
return WS_BUFFER_E;
1872+
#ifndef USE_WINDOWS_API
1873+
#ifndef WOLFSSH_FATFS
1874+
{
1875+
word32 mode = 040755;
1876+
if (atr.flags & WOLFSSH_FILEATRB_PERM) {
1877+
mode = atr.per;
1878+
}
1879+
else {
1880+
WLOG(WS_LOG_SFTP, "No permission attribute, using default");
18801881
}
1882+
ret = WMKDIR(ssh->fs, dir, mode);
18811883
}
1882-
1883-
#ifndef USE_WINDOWS_API
1884-
ret = WMKDIR(ssh->fs, dir, mode);
1884+
#else /* WOLFSSH_FATFS */
1885+
/* WMKDIR for FatFS drops mode argument */
1886+
ret = WMKDIR(ssh->fs, dir, 0);
1887+
#endif /* WOLFSSH_FATFS */
18851888
#else /* USE_WINDOWS_API */
18861889
ret = WS_CreateDirectoryA(dir, ssh->ctx->heap) == 0;
18871890
#endif /* USE_WINDOWS_API */

0 commit comments

Comments
 (0)