From: Tobias Stoeckmann Date: Sat, 18 Apr 2026 16:17:13 +0000 (+0200) Subject: fallocate: Add range check X-Git-Url: http://git.ipfire.org/gitweb/?a=commitdiff_plain;h=da32ad3ded0a53615b928014d5fd004c55bfee28;p=thirdparty%2Futil-linux.git fallocate: Add range check Make sure that offset + length does not overflow off_t. Signed-off-by: Tobias Stoeckmann --- diff --git a/sys-utils/fallocate.c b/sys-utils/fallocate.c index 622e0c39c..ff063fcd5 100644 --- a/sys-utils/fallocate.c +++ b/sys-utils/fallocate.c @@ -479,6 +479,10 @@ int main(int argc, char **argv) if (length == 0) errx(EXIT_FAILURE, _("invalid length")); } + if (length > SINT_MAX(off_t) - offset) { + errno = ERANGE; + err(EXIT_FAILURE, _("invalid range specified")); + } /* O_CREAT makes sense only for the default fallocate(2) behavior * when mode is no specified and new space is allocated */