From: Rusty Russell Date: Wed, 6 Jul 2011 05:17:44 +0000 (+0930) Subject: ccan/tally: don't use SIZE_MAX. X-Git-Url: http://git.samba.org/?p=kai%2Fsamba.git;a=commitdiff_plain;h=c019302e65051f214c5ea2ef908aa0ef79c8b12e ccan/tally: don't use SIZE_MAX. Michael Adam points out this broke the build farm (ie. OSF1 axp V5.1 2650 alpha) so fixed in CCAN and imported from af7a902d74a7926693f55da9e21a67dde46931d4: Turns out it's not standard (thanks Samba build farm!) And the previous test had a hole in it anyway. This one is more conservative. Signed-off-by: Rusty Russell Autobuild-User: Rusty Russell Autobuild-Date: Wed Jul 6 08:34:05 CEST 2011 on sn-devel-104 --- diff --git a/lib/ccan/tally/tally.c b/lib/ccan/tally/tally.c index b1839befe3b..396474b250e 100644 --- a/lib/ccan/tally/tally.c +++ b/lib/ccan/tally/tally.c @@ -27,8 +27,8 @@ struct tally *tally_new(unsigned buckets) if (buckets == 0) buckets = 1; - /* Check for overflow. */ - if (buckets && SIZE_MAX / buckets < sizeof(tally->counts[0])) + /* Overly cautious check for overflow. */ + if (sizeof(*tally) * buckets / sizeof(*tally) != buckets) return NULL; tally = malloc(sizeof(*tally) + sizeof(tally->counts[0])*(buckets-1)); if (tally) {