Skip to content

Commit e931db6

Browse files
ejohnstownpadelsbach
authored andcommitted
sftp: check ParseAttributes return in RecvOpen
Set ret = WS_BAD_FILE_E and jump to cleanup on parse failure instead of ignoring the return value. Issue: CID 645982
1 parent 0068d52 commit e931db6

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

src/wolfsftp.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2069,7 +2069,12 @@ int wolfSSH_SFTP_RecvOpen(WOLFSSH* ssh, int reqId, byte* data, word32 maxSz)
20692069
}
20702070

20712071
/* @TODO handle attributes */
2072-
SFTP_ParseAttributes_buffer(ssh, &atr, data, &idx, maxSz);
2072+
if (SFTP_ParseAttributes_buffer(ssh, &atr, data, &idx, maxSz)
2073+
!= WS_SUCCESS) {
2074+
ret = WS_BAD_FILE_E;
2075+
goto cleanup;
2076+
}
2077+
20732078
if ((reason & WOLFSSH_FXF_READ) && (reason & WOLFSSH_FXF_WRITE)) {
20742079
WLOG(WS_LOG_SFTP, "Opening file with WOLFSSH_O_RDWR");
20752080
m |= WOLFSSH_O_RDWR;
@@ -2277,7 +2282,11 @@ int wolfSSH_SFTP_RecvOpen(WOLFSSH* ssh, int reqId, byte* data, word32 maxSz)
22772282

22782283
#if 0
22792284
/* @TODO handle attributes */
2280-
SFTP_ParseAttributes_buffer(ssh, &atr, data, &idx, maxSz);
2285+
if (SFTP_ParseAttributes_buffer(ssh, &atr, data, &idx, maxSz)
2286+
!= WS_SUCCESS) {
2287+
ret = WS_BAD_FILE_E;
2288+
goto cleanup;
2289+
}
22812290
#endif
22822291

22832292
if (reason & WOLFSSH_FXF_READ) {

0 commit comments

Comments
 (0)