From 90df84eb2e05926351cc7df661712c97779c9163 Mon Sep 17 00:00:00 2001 From: Scott Worley Date: Wed, 13 Sep 2023 11:40:48 -0700 Subject: [PATCH] =?utf8?q?appease=20clang-tidy:=20Careful=20of=20size=5Ft?= =?utf8?q?=E2=86=92int=20narrowing=20conversion?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Why does fgets take an int instead of a size_t? :( --- tl-append-test.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tl-append-test.c b/tl-append-test.c index 4d51c38..08cf800 100644 --- a/tl-append-test.c +++ b/tl-append-test.c @@ -3,6 +3,7 @@ #include #include #include +#include #include #include #include @@ -89,6 +90,8 @@ static void verify_log_contents(ex_t exps[]) { die_err("Error opening log file"); for (size_t i = 0; !is_end(exps[i]); i++) { size_t len = TIMESTAMP_LEN + 1 + strlen(exps[i].message); + if (len > INT_MAX - 1) + die("message too long"); char *buf = (char *)malloc(len + 2); if (fgets(buf, len + 1, f) == NULL) die("Error reading log file"); -- 2.44.1