Skip to content

Commit 0838634

Browse files
J-Goldackerejohnstown
authored andcommitted
set fName to NULL after free
otherwise wolfSSH_SFTPNAME_free would crash afterwards
1 parent c688299 commit 0838634

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
@@ -3151,19 +3151,22 @@ static int wolfSSH_SFTPNAME_readdir(WOLFSSH* ssh, WDIR* dir, WS_SFTPNAME* out,
31513151
>= (int)sizeof(r)) {
31523152
WLOG(WS_LOG_SFTP, "Path length too large");
31533153
WFREE(out->fName, out->heap, DYNTYPE_SFTP);
3154+
out->fName = NULL;
31543155
return WS_FATAL_ERROR;
31553156
}
31563157

31573158
if (wolfSSH_RealPath(ssh->sftpDefaultPath, r, s, sizeof(s)) < 0) {
31583159
WLOG(WS_LOG_SFTP, "Error cleaning path to get attributes");
31593160
WFREE(out->fName, out->heap, DYNTYPE_SFTP);
3161+
out->fName = NULL;
31603162
return WS_FATAL_ERROR;
31613163
}
31623164
if (SFTP_GetAttributes(ssh->fs, s, &out->atrb, 0, ssh->ctx->heap)
31633165
!= WS_SUCCESS) {
31643166
WLOG(WS_LOG_SFTP, "Unable to get attribute values for %s",
31653167
out->fName);
31663168
WFREE(out->fName, out->heap, DYNTYPE_SFTP);
3169+
out->fName = NULL;
31673170
return WS_FATAL_ERROR;
31683171
}
31693172
}
@@ -3172,6 +3175,7 @@ static int wolfSSH_SFTPNAME_readdir(WOLFSSH* ssh, WDIR* dir, WS_SFTPNAME* out,
31723175
if (SFTP_CreateLongName(out) != WS_SUCCESS) {
31733176
WLOG(WS_LOG_DEBUG, "Error creating long name for %s", out->fName);
31743177
WFREE(out->fName, out->heap, DYNTYPE_SFTP);
3178+
out->fName = NULL;
31753179
return WS_FATAL_ERROR;
31763180
}
31773181
return WS_SUCCESS;

0 commit comments

Comments
 (0)