From 295bef07d6bd18cd58746e46b400faadfb54b712 Mon Sep 17 00:00:00 2001 From: Corinna Vinschen Date: Tue, 5 Dec 2023 22:08:01 +0100 Subject: Cygwin: posix_fallocate(3): fix offset and length sanity check - len must not be <= 0 - offset + len must not exceed off_t (max. file size) Fixes: 7636b5859062 ("* autoload.cc (NtSetInformationFile): Define.") Signed-off-by: Corinna Vinschen --- winsup/cygwin/syscalls.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'winsup') diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc index b73391d8f..3edb55bc6 100644 --- a/winsup/cygwin/syscalls.cc +++ b/winsup/cygwin/syscalls.cc @@ -3030,8 +3030,10 @@ extern "C" int posix_fallocate (int fd, off_t offset, off_t len) { int res = 0; - if (offset < 0 || len == 0) + if (offset < 0 || len <= 0) res = EINVAL; + else if (INT64_MAX - len < offset) + res = EFBIG; else { cygheap_fdget cfd (fd); -- cgit v1.2.3