From 3d0d5dccc1789c53e2a800417e1a9c160e89d6c1 Mon Sep 17 00:00:00 2001 From: Juli Mallett Date: Thu, 6 Jun 2002 20:29:39 +0000 Subject: [PATCH] Cast arg_max to size_t when comparing it (times 4, plus 1) against SIZE_MAX. I was worried about truncation of arg_max by this cast, but if it gets truncated, we know it'll obviously be greater than SIZE_MAX anyway. Big pointy hat to: jmallett Submitted by: keramida --- bin/ps/fmt.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bin/ps/fmt.c b/bin/ps/fmt.c index 92638869227d..3703ace22c6e 100644 --- a/bin/ps/fmt.c +++ b/bin/ps/fmt.c @@ -70,7 +70,8 @@ shquote(char **argv) if (buf == NULL) { if ((arg_max = sysconf(_SC_ARG_MAX)) == -1) errx(1, "sysconf _SC_ARG_MAX failed"); - if (arg_max >= LONG_MAX / 4 || 4 * arg_max + 1 > SIZE_MAX) + if (arg_max >= LONG_MAX / 4 || + 4 * (size_t)arg_max + 1 > SIZE_MAX) errx(1, "sysconf _SC_ARG_MAX preposterously large"); buf_size = 4 * arg_max + 1; if ((buf = malloc(buf_size)) == NULL)