From cdf3099c68f21dd74b7eb9574b323f38eaa816ea Mon Sep 17 00:00:00 2001 From: Alex Hirsch Date: Tue, 9 Mar 2021 02:37:35 +0100 Subject: Add parameter checkes to FileAccess get_buffer functions fix #46540 --- drivers/unix/file_access_unix.cpp | 2 ++ drivers/windows/file_access_windows.cpp | 2 ++ 2 files changed, 4 insertions(+) (limited to 'drivers') diff --git a/drivers/unix/file_access_unix.cpp b/drivers/unix/file_access_unix.cpp index 6b24a85ff6..31ec9d4c93 100644 --- a/drivers/unix/file_access_unix.cpp +++ b/drivers/unix/file_access_unix.cpp @@ -240,6 +240,8 @@ uint8_t FileAccessUnix::get_8() const { } int FileAccessUnix::get_buffer(uint8_t *p_dst, int p_length) const { + ERR_FAIL_COND_V(!p_dst, -1); + ERR_FAIL_COND_V(p_length < 0, -1); ERR_FAIL_COND_V_MSG(!f, -1, "File must be opened before use."); int read = fread(p_dst, 1, p_length, f); check_errors(); diff --git a/drivers/windows/file_access_windows.cpp b/drivers/windows/file_access_windows.cpp index 35f61c0623..17f68ecdac 100644 --- a/drivers/windows/file_access_windows.cpp +++ b/drivers/windows/file_access_windows.cpp @@ -253,6 +253,8 @@ uint8_t FileAccessWindows::get_8() const { } int FileAccessWindows::get_buffer(uint8_t *p_dst, int p_length) const { + ERR_FAIL_COND_V(!p_dst, -1); + ERR_FAIL_COND_V(p_length < 0, -1); ERR_FAIL_COND_V(!f, -1); if (flags == READ_WRITE || flags == WRITE_READ) { if (prev_op == WRITE) { -- cgit v1.2.3