From: Robert Kessl Date: Mon, 28 Jul 2014 11:54:26 +0000 (+0200) Subject: xtypes: overflow detection updated X-Git-Tag: v6.1~3^2~35 X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;h=14569005ceedc6c2ce34526b8a6ac6778938aa47;p=libucw.git xtypes: overflow detection updated --- diff --git a/ucw/table-types.c b/ucw/table-types.c index 84d317c2..4da3ccc8 100644 --- a/ucw/table-types.c +++ b/ucw/table-types.c @@ -117,10 +117,9 @@ static const char *xt_size_parse(const char *str, void *dest, struct mempool *po return mp_printf(pool, "Invalid units: '%s'.", str); } - // FIXME: Detect overflow? + // Overflow detection u64 num = xt_size_units[unit_idx].num; - if((parsed && UINT64_MAX / parsed < num) || - (num && UINT64_MAX / num < parsed)) { + if(parsed && UINT64_MAX / parsed < num) { return mp_printf(pool, "Size too large: '%s'.", str); }