From f9cbd99a753c10503e29605557d9ab9007f13235 Mon Sep 17 00:00:00 2001 From: Peter Rajnoha Date: Mon, 24 Jun 2024 09:25:13 +0200 Subject: [PATCH] base: util: check provided buffer len fits ssize_t in sid_util_fd_read_all --- src/base/util.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/base/util.c b/src/base/util.c index a083ef2c..36689843 100644 --- a/src/base/util.c +++ b/src/base/util.c @@ -21,6 +21,7 @@ #include #include +#include #include #include #include @@ -59,6 +60,9 @@ ssize_t sid_util_fd_read_all(int fd, void *buf, size_t len) { ssize_t n, total = 0; + if (len > SSIZE_MAX) + return -ERANGE; + while (len) { n = read(fd, buf, len); if (n < 0) {