Skip to content

Commit b2f6f70

Browse files
committed
set fName to NULL after free
otherwise wolfSSH_SFTPNAME_free would crash afterwards
1 parent 4b5877f commit b2f6f70

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

src/wolfsftp.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3152,19 +3152,22 @@ static int wolfSSH_SFTPNAME_readdir(WOLFSSH* ssh, WDIR* dir, WS_SFTPNAME* out,
31523152
>= (int)sizeof(r)) {
31533153
WLOG(WS_LOG_SFTP, "Path length too large");
31543154
WFREE(out->fName, out->heap, DYNTYPE_SFTP);
3155+
out->fName = NULL;
31553156
return WS_FATAL_ERROR;
31563157
}
31573158

31583159
if (wolfSSH_RealPath(ssh->sftpDefaultPath, r, s, sizeof(s)) < 0) {
31593160
WLOG(WS_LOG_SFTP, "Error cleaning path to get attributes");
31603161
WFREE(out->fName, out->heap, DYNTYPE_SFTP);
3162+
out->fName = NULL;
31613163
return WS_FATAL_ERROR;
31623164
}
31633165
if (SFTP_GetAttributes(ssh->fs, s, &out->atrb, 0, ssh->ctx->heap)
31643166
!= WS_SUCCESS) {
31653167
WLOG(WS_LOG_SFTP, "Unable to get attribute values for %s",
31663168
out->fName);
31673169
WFREE(out->fName, out->heap, DYNTYPE_SFTP);
3170+
out->fName = NULL;
31683171
return WS_FATAL_ERROR;
31693172
}
31703173
}
@@ -3173,6 +3176,7 @@ static int wolfSSH_SFTPNAME_readdir(WOLFSSH* ssh, WDIR* dir, WS_SFTPNAME* out,
31733176
if (SFTP_CreateLongName(out) != WS_SUCCESS) {
31743177
WLOG(WS_LOG_DEBUG, "Error creating long name for %s", out->fName);
31753178
WFREE(out->fName, out->heap, DYNTYPE_SFTP);
3179+
out->fName = NULL;
31763180
return WS_FATAL_ERROR;
31773181
}
31783182
return WS_SUCCESS;

0 commit comments

Comments
 (0)