Skip to content

Commit 9d5ea1f

Browse files
committed
call sftp.close in an ensure block in case seomthing throws an excpetion. we probably dont *have* to do this (as teh SFTP session will be torn down either way), but it seems like best practise *to* so this.
1 parent e191697 commit 9d5ea1f

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

modules/auxiliary/gather/progress_moveit_sftp_fileread_cve_2024_5806.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,11 +188,11 @@ def read_file(sftp, file_path)
188188
print_error('SFTP read failed.')
189189
end
190190
end
191-
192-
sftp.close(open_response[:handle])
193191
else
194192
print_error('SFTP open failed. Is the TARGETFILE path correct?')
195193
end
194+
ensure
195+
sftp.close(open_response[:handle]) if open_response.ok?
196196
end
197197
end
198198

0 commit comments

Comments
 (0)