Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/echoserver/echoserver.c
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ static void printKeyCompleteText(WOLFSSH* ssh, WS_Text id, const char* tag)
size_t ret;

ret = wolfSSH_GetText(ssh, id, str, strSz);
if (ret == strSz) {
if (ret >= strSz) {
printf("\tString size was not large enough for %s\n", tag);
}
printf("\t%-30s : %s\n", tag, str);
Expand Down
3 changes: 1 addition & 2 deletions examples/sftpclient/sftpclient.c
Original file line number Diff line number Diff line change
Expand Up @@ -667,7 +667,6 @@ static int doCmds(func_args* args)
}

if ((pt = WSTRNSTR(msg, "mkdir", sizeof(msg))) != NULL) {
WS_SFTP_FILEATRB atrb;
int sz;
char* f = NULL;

Expand All @@ -691,7 +690,7 @@ static int doCmds(func_args* args)

do {
err = WS_SUCCESS;
if ((ret = wolfSSH_SFTP_MKDIR(ssh, pt, &atrb)) != WS_SUCCESS) {
if ((ret = wolfSSH_SFTP_MKDIR(ssh, pt, NULL)) != WS_SUCCESS) {
err = wolfSSH_get_error(ssh);
if (ret == WS_PERMISSIONS) {
if (SFTP_FPUTS(args, "Insufficient permissions\n") < 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ static void printKeyCompleteText(WOLFSSH* ssh, WS_Text id, const char* tag)
size_t ret;

ret = wolfSSH_GetText(ssh, id, str, strSz);
if (ret == strSz) {
if (ret >= strSz) {
printf("\tString size was not large enough for %s\n", tag);
}
printf("\t%-30s : %s\n", tag, str);
Expand Down
64 changes: 4 additions & 60 deletions src/internal.c
Original file line number Diff line number Diff line change
Expand Up @@ -20071,6 +20071,10 @@ int SendIgnore(WOLFSSH* ssh, const unsigned char* data, word32 dataSz)
if (ssh == NULL || (data == NULL && dataSz > 0))
ret = WS_BAD_ARGUMENT;

/* Also keeps the size sums in PreparePacket() from wrapping. */
if (ret == WS_SUCCESS && dataSz > MAX_IGNORE_DATA_SZ)
ret = WS_BAD_ARGUMENT;

if (ret == WS_SUCCESS)
ret = PreparePacket(ssh, MSG_ID_SZ + LENGTH_SZ + dataSz);

Expand Down Expand Up @@ -24923,66 +24927,6 @@ int SendChannelSuccess(WOLFSSH* ssh, word32 channelId, int success)


#if defined(WOLFSSH_SFTP) || defined(WOLFSSH_SCP)
/* Checks if 'in' is absolute path, if not the returns the concat. of
* 'defaultPath' | 'in'. This leaves 'in' as-is and does not handle
* simplification of the path, such as removing ../
*
* Sanity checks outSz and then adjusts it for the size used
* returns WS_SUCCESS on success
*/
int wolfSSH_GetPath(const char* defaultPath, byte* in, word32 inSz,
char* out, word32* outSz)
{
word32 curSz = 0;

if (out != NULL) {
WMEMSET(out, 0, *outSz);
}

if (inSz == 0 || (!WOLFSSH_SFTP_IS_DELIM(in[0]) &&
!WOLFSSH_SFTP_IS_WINPATH(inSz, in))) {
if (defaultPath != NULL) {
curSz = (word32)WSTRLEN(defaultPath);
if (out != NULL && curSz >= *outSz) {
return WS_INVALID_PATH_E;
}
if (out != NULL) {
WSTRNCPY(out, defaultPath, *outSz);
if (out[curSz] != '/') {
out[curSz] = '/';
curSz++;
}
}
}
}

if (out != NULL) {
if (curSz + inSz < *outSz) {
WMEMCPY(out + curSz, in, inSz);
}
}
curSz += inSz;
if (out != NULL) {
if (!WOLFSSH_SFTP_IS_DELIM(out[0])) {
if (curSz + 1 < *outSz) {
WMEMMOVE(out+1, out, curSz);
out[0] = '/';
}
curSz++;
}
if (curSz < *outSz) {
out[curSz] = 0;
}
else {
return WS_BUFFER_E;
}
}
*outSz = curSz;

return WS_SUCCESS;
}


/* Cleans up absolute path, OS specific.
* returns size of new path on success (strlen sz) and negative values on fail*/
int wolfSSH_CleanPath(WOLFSSH* ssh, char* in, int inSz)
Expand Down
Loading
Loading