]> sourceware.org Git - newlib-cygwin.git/commitdiff
Cygwin: posix_fallocate(3): fix offset and length sanity check
authorCorinna Vinschen <corinna@vinschen.de>
Tue, 5 Dec 2023 21:08:01 +0000 (22:08 +0100)
committerCorinna Vinschen <corinna@vinschen.de>
Tue, 5 Dec 2023 21:19:05 +0000 (22:19 +0100)
- 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 <corinna@vinschen.de>
winsup/cygwin/syscalls.cc

index b73391d8f84e82a373f27a56b5dc4cf49a134bb3..3edb55bc608fc68f3b4c791fcc80c9c465a7e151 100644 (file)
@@ -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);
This page took 0.039222 seconds and 5 git commands to generate.