mirror of https://github.com/wolfSSL/wolfssh.git
Merge pull request #568 from JacobBarthelmeh/sftp
commit
ad2b0d7b99
|
|
@ -1697,6 +1697,11 @@ int wolfSSH_SFTP_RecvRMDIR(WOLFSSH* ssh, int reqId, byte* data, word32 maxSz)
|
|||
|
||||
WLOG(WS_LOG_SFTP, "Receiving WOLFSSH_FTP_RMDIR");
|
||||
|
||||
if (maxSz < UINT32_SZ) {
|
||||
/* not enough for an ato32 call */
|
||||
return WS_BUFFER_E;
|
||||
}
|
||||
|
||||
ato32(data + idx, &sz); idx += UINT32_SZ;
|
||||
if (sz > maxSz - idx) {
|
||||
return WS_BUFFER_E;
|
||||
|
|
@ -1772,6 +1777,11 @@ int wolfSSH_SFTP_RecvMKDIR(WOLFSSH* ssh, int reqId, byte* data, word32 maxSz)
|
|||
|
||||
WLOG(WS_LOG_SFTP, "Receiving WOLFSSH_FTP_MKDIR");
|
||||
|
||||
if (maxSz < UINT32_SZ) {
|
||||
/* not enough for an ato32 call */
|
||||
return WS_BUFFER_E;
|
||||
}
|
||||
|
||||
ato32(data + idx, &sz); idx += UINT32_SZ;
|
||||
if (sz > maxSz - idx) {
|
||||
return WS_BUFFER_E;
|
||||
|
|
@ -1971,6 +1981,11 @@ int wolfSSH_SFTP_RecvOpen(WOLFSSH* ssh, int reqId, byte* data, word32 maxSz)
|
|||
return WS_FATAL_ERROR;
|
||||
}
|
||||
|
||||
if (maxSz < UINT32_SZ) {
|
||||
/* not enough for an ato32 call */
|
||||
return WS_BUFFER_E;
|
||||
}
|
||||
|
||||
ato32(data + idx, &sz); idx += UINT32_SZ;
|
||||
if (sz > maxSz - idx) {
|
||||
return WS_BUFFER_E;
|
||||
|
|
@ -2099,6 +2114,11 @@ int wolfSSH_SFTP_RecvOpen(WOLFSSH* ssh, int reqId, byte* data, word32 maxSz)
|
|||
return WS_FATAL_ERROR;
|
||||
}
|
||||
|
||||
if (maxSz < UINT32_SZ) {
|
||||
/* not enough for an ato32 call */
|
||||
return WS_BUFFER_E;
|
||||
}
|
||||
|
||||
ato32(data + idx, &sz); idx += UINT32_SZ;
|
||||
if (sz > maxSz - idx) {
|
||||
return WS_BUFFER_E;
|
||||
|
|
@ -2237,6 +2257,11 @@ int wolfSSH_SFTP_RecvOpenDir(WOLFSSH* ssh, int reqId, byte* data, word32 maxSz)
|
|||
return WS_FATAL_ERROR;
|
||||
}
|
||||
|
||||
if (maxSz < UINT32_SZ) {
|
||||
/* not enough for an ato32 call */
|
||||
return WS_BUFFER_E;
|
||||
}
|
||||
|
||||
/* get directory name */
|
||||
ato32(data + idx, &sz); idx += UINT32_SZ;
|
||||
if (sz > maxSz - idx) {
|
||||
|
|
@ -2346,6 +2371,11 @@ int wolfSSH_SFTP_RecvOpenDir(WOLFSSH* ssh, int reqId, byte* data, word32 maxSz)
|
|||
return WS_FATAL_ERROR;
|
||||
}
|
||||
|
||||
if (maxSz < UINT32_SZ) {
|
||||
/* not enough for an ato32 call */
|
||||
return WS_BUFFER_E;
|
||||
}
|
||||
|
||||
/* get directory name */
|
||||
ato32(data + idx, &sz);
|
||||
idx += UINT32_SZ;
|
||||
|
|
@ -3097,6 +3127,11 @@ int wolfSSH_SFTP_RecvReadDir(WOLFSSH* ssh, int reqId, byte* data, word32 maxSz)
|
|||
dir = INVALID_HANDLE_VALUE;
|
||||
#endif
|
||||
|
||||
if (maxSz < UINT32_SZ) {
|
||||
/* not enough for an ato32 call */
|
||||
return WS_BUFFER_E;
|
||||
}
|
||||
|
||||
/* get directory handle */
|
||||
ato32(data + idx, &sz); idx += UINT32_SZ;
|
||||
if (sz + idx > maxSz || sz > WOLFSSH_MAX_HANDLE) {
|
||||
|
|
@ -3280,6 +3315,11 @@ int wolfSSH_SFTP_RecvWrite(WOLFSSH* ssh, int reqId, byte* data, word32 maxSz)
|
|||
|
||||
WLOG(WS_LOG_SFTP, "Receiving WOLFSSH_FTP_WRITE");
|
||||
|
||||
if (maxSz < UINT32_SZ) {
|
||||
/* not enough for an ato32 call */
|
||||
return WS_BUFFER_E;
|
||||
}
|
||||
|
||||
/* get file handle */
|
||||
ato32(data + idx, &sz); idx += UINT32_SZ;
|
||||
if (sz + idx > maxSz || sz > WOLFSSH_MAX_HANDLE) {
|
||||
|
|
@ -3364,6 +3404,11 @@ int wolfSSH_SFTP_RecvWrite(WOLFSSH* ssh, int reqId, byte* data, word32 maxSz)
|
|||
|
||||
WLOG(WS_LOG_SFTP, "Receiving WOLFSSH_FTP_WRITE");
|
||||
|
||||
if (maxSz < UINT32_SZ) {
|
||||
/* not enough for an ato32 call */
|
||||
return WS_BUFFER_E;
|
||||
}
|
||||
|
||||
/* get file handle */
|
||||
ato32(data + idx, &sz);
|
||||
idx += UINT32_SZ;
|
||||
|
|
@ -3455,6 +3500,11 @@ int wolfSSH_SFTP_RecvRead(WOLFSSH* ssh, int reqId, byte* data, word32 maxSz)
|
|||
|
||||
WLOG(WS_LOG_SFTP, "Receiving WOLFSSH_FTP_READ");
|
||||
|
||||
if (maxSz < UINT32_SZ) {
|
||||
/* not enough for an ato32 call */
|
||||
return WS_BUFFER_E;
|
||||
}
|
||||
|
||||
/* get file handle */
|
||||
ato32(data + idx, &sz); idx += UINT32_SZ;
|
||||
if (sz + idx > maxSz || sz > WOLFSSH_MAX_HANDLE) {
|
||||
|
|
@ -3550,6 +3600,11 @@ int wolfSSH_SFTP_RecvRead(WOLFSSH* ssh, int reqId, byte* data, word32 maxSz)
|
|||
|
||||
WLOG(WS_LOG_SFTP, "Receiving WOLFSSH_FTP_READ");
|
||||
|
||||
if (maxSz < UINT32_SZ) {
|
||||
/* not enough for an ato32 call */
|
||||
return WS_BUFFER_E;
|
||||
}
|
||||
|
||||
/* get file handle */
|
||||
ato32(data + idx, &sz); idx += UINT32_SZ;
|
||||
if (sz > maxSz - idx || sz > WOLFSSH_MAX_HANDLE) {
|
||||
|
|
@ -3667,6 +3722,11 @@ int wolfSSH_SFTP_RecvClose(WOLFSSH* ssh, int reqId, byte* data, word32 maxSz)
|
|||
|
||||
WLOG(WS_LOG_SFTP, "Receiving WOLFSSH_FTP_CLOSE");
|
||||
|
||||
if (maxSz < UINT32_SZ) {
|
||||
/* not enough for an ato32 call */
|
||||
return WS_BUFFER_E;
|
||||
}
|
||||
|
||||
/* get file handle */
|
||||
ato32(data + idx, &sz); idx += UINT32_SZ;
|
||||
if (sz + idx > maxSz || sz > WOLFSSH_MAX_HANDLE) {
|
||||
|
|
@ -3748,6 +3808,11 @@ int wolfSSH_SFTP_RecvClose(WOLFSSH* ssh, int reqId, byte* data, word32 maxSz)
|
|||
|
||||
WLOG(WS_LOG_SFTP, "Receiving WOLFSSH_FTP_CLOSE");
|
||||
|
||||
if (maxSz < UINT32_SZ) {
|
||||
/* not enough for an ato32 call */
|
||||
return WS_BUFFER_E;
|
||||
}
|
||||
|
||||
/* get file handle */
|
||||
ato32(data + idx, &sz); idx += UINT32_SZ;
|
||||
if (sz + idx > maxSz || sz > WOLFSSH_MAX_HANDLE) {
|
||||
|
|
@ -3838,6 +3903,11 @@ int wolfSSH_SFTP_RecvRemove(WOLFSSH* ssh, int reqId, byte* data, word32 maxSz)
|
|||
|
||||
WLOG(WS_LOG_SFTP, "Receiving WOLFSSH_FTP_REMOVE");
|
||||
|
||||
if (maxSz < UINT32_SZ) {
|
||||
/* not enough for an ato32 call */
|
||||
return WS_BUFFER_E;
|
||||
}
|
||||
|
||||
/* get file name */
|
||||
ato32(data + idx, &sz); idx += UINT32_SZ;
|
||||
if (sz + idx > maxSz || sz > WOLFSSH_MAX_HANDLE) {
|
||||
|
|
@ -3924,6 +3994,11 @@ int wolfSSH_SFTP_RecvRename(WOLFSSH* ssh, int reqId, byte* data, word32 maxSz)
|
|||
|
||||
WLOG(WS_LOG_SFTP, "Receiving WOLFSSH_FTP_RENAME");
|
||||
|
||||
if (maxSz < UINT32_SZ) {
|
||||
/* not enough for an ato32 call */
|
||||
return WS_BUFFER_E;
|
||||
}
|
||||
|
||||
/* get old file name */
|
||||
ato32(data + idx, &sz); idx += UINT32_SZ;
|
||||
if (sz > maxSz - idx) {
|
||||
|
|
@ -4666,6 +4741,11 @@ int wolfSSH_SFTP_RecvFSTAT(WOLFSSH* ssh, int reqId, byte* data, word32 maxSz)
|
|||
|
||||
WLOG(WS_LOG_SFTP, "Receiving WOLFSSH_FTP_FSTAT");
|
||||
|
||||
if (maxSz < UINT32_SZ) {
|
||||
/* not enough for an ato32 call */
|
||||
return WS_BUFFER_E;
|
||||
}
|
||||
|
||||
ato32(data + idx, &handleSz); idx += UINT32_SZ;
|
||||
if (handleSz + idx > maxSz) {
|
||||
return WS_BUFFER_E;
|
||||
|
|
@ -4734,6 +4814,11 @@ int wolfSSH_SFTP_RecvSTAT(WOLFSSH* ssh, int reqId, byte* data, word32 maxSz)
|
|||
|
||||
WLOG(WS_LOG_SFTP, "Receiving WOLFSSH_FTP_STAT");
|
||||
|
||||
if (maxSz < UINT32_SZ) {
|
||||
/* not enough for an ato32 call */
|
||||
return WS_BUFFER_E;
|
||||
}
|
||||
|
||||
ato32(data + idx, &sz); idx += UINT32_SZ;
|
||||
if (sz > maxSz - idx) {
|
||||
return WS_BUFFER_E;
|
||||
|
|
@ -4813,6 +4898,11 @@ int wolfSSH_SFTP_RecvLSTAT(WOLFSSH* ssh, int reqId, byte* data, word32 maxSz)
|
|||
|
||||
WLOG(WS_LOG_SFTP, "Receiving WOLFSSH_FTP_LSTAT");
|
||||
|
||||
if (maxSz < UINT32_SZ) {
|
||||
/* not enough for an ato32 call */
|
||||
return WS_BUFFER_E;
|
||||
}
|
||||
|
||||
ato32(data + idx, &sz); idx += UINT32_SZ;
|
||||
if (sz > maxSz - idx) {
|
||||
return WS_BUFFER_E;
|
||||
|
|
@ -4954,6 +5044,11 @@ int wolfSSH_SFTP_RecvSetSTAT(WOLFSSH* ssh, int reqId, byte* data, word32 maxSz)
|
|||
|
||||
WLOG(WS_LOG_SFTP, "Receiving WOLFSSH_FTP_SETSTAT");
|
||||
|
||||
if (maxSz < UINT32_SZ) {
|
||||
/* not enough for an ato32 call */
|
||||
return WS_BUFFER_E;
|
||||
}
|
||||
|
||||
ato32(data + idx, &sz); idx += UINT32_SZ;
|
||||
if (sz > maxSz - idx) {
|
||||
return WS_BUFFER_E;
|
||||
|
|
|
|||
Loading…
Reference in New Issue