Skip to content

Commit e9416ef

Browse files
Fix minor issues and Add test vectors
1 parent 4b948e6 commit e9416ef

4 files changed

Lines changed: 15 additions & 14 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: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1835,7 +1835,7 @@ 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;
@@ -1866,18 +1866,16 @@ int wolfSSH_SFTP_RecvMKDIR(WOLFSSH* ssh, int reqId, byte* data, word32 maxSz)
18661866
return ret;
18671867
}
18681868

1869-
if (GetUint32(&attrFlags, data, maxSz, &idx) != WS_SUCCESS) {
1869+
if (SFTP_ParseAttributes_buffer(ssh, &atr, data, &idx, maxSz)
1870+
!= WS_SUCCESS) {
18701871
return WS_BUFFER_E;
18711872
}
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;
1873+
if (atr.flags & WOLFSSH_FILEATRB_PERM) {
1874+
mode = atr.per;
18761875
}
18771876
else {
1878-
if (GetUint32(&mode, data, maxSz, &idx) != WS_SUCCESS) {
1879-
return WS_BUFFER_E;
1880-
}
1877+
WLOG(WS_LOG_SFTP, "No permission attribute, using default");
1878+
mode = 040755;
18811879
}
18821880

18831881
#ifndef USE_WINDOWS_API

0 commit comments

Comments
 (0)