mirror of https://github.com/wolfSSL/wolfssh.git
Merge pull request #806 from LinuxJedi/fs-fixes
Fix double-free on `wolfSSH_SFTPNAME_readdir`pull/809/head
commit
e32ea9078c
|
@ -3228,12 +3228,16 @@ static int wolfSSH_SFTPNAME_readdir(WOLFSSH* ssh, WDIR* dir, WS_SFTPNAME* out,
|
||||||
>= (int)sizeof(r)) {
|
>= (int)sizeof(r)) {
|
||||||
WLOG(WS_LOG_SFTP, "Path length too large");
|
WLOG(WS_LOG_SFTP, "Path length too large");
|
||||||
WFREE(out->fName, out->heap, DYNTYPE_SFTP);
|
WFREE(out->fName, out->heap, DYNTYPE_SFTP);
|
||||||
|
out->fName = NULL;
|
||||||
|
out->fSz = 0;
|
||||||
return WS_FATAL_ERROR;
|
return WS_FATAL_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wolfSSH_RealPath(ssh->sftpDefaultPath, r, s, sizeof(s)) < 0) {
|
if (wolfSSH_RealPath(ssh->sftpDefaultPath, r, s, sizeof(s)) < 0) {
|
||||||
WFREE(out->fName, out->heap, DYNTYPE_SFTP);
|
WFREE(out->fName, out->heap, DYNTYPE_SFTP);
|
||||||
WLOG(WS_LOG_SFTP, "Error cleaning path to get attributes");
|
WLOG(WS_LOG_SFTP, "Error cleaning path to get attributes");
|
||||||
|
out->fName = NULL;
|
||||||
|
out->fSz = 0;
|
||||||
return WS_FATAL_ERROR;
|
return WS_FATAL_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3248,6 +3252,8 @@ static int wolfSSH_SFTPNAME_readdir(WOLFSSH* ssh, WDIR* dir, WS_SFTPNAME* out,
|
||||||
if (SFTP_CreateLongName(out) != WS_SUCCESS) {
|
if (SFTP_CreateLongName(out) != WS_SUCCESS) {
|
||||||
WLOG(WS_LOG_DEBUG, "Error creating long name for %s", out->fName);
|
WLOG(WS_LOG_DEBUG, "Error creating long name for %s", out->fName);
|
||||||
WFREE(out->fName, out->heap, DYNTYPE_SFTP);
|
WFREE(out->fName, out->heap, DYNTYPE_SFTP);
|
||||||
|
out->fName = NULL;
|
||||||
|
out->fSz = 0;
|
||||||
return WS_FATAL_ERROR;
|
return WS_FATAL_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue