From 54dde0cff42c7f1363cf28d16ab6f54232b672e8 Mon Sep 17 00:00:00 2001 From: Robert Kessl Date: Fri, 25 Jul 2014 17:28:59 +0200 Subject: [PATCH] tableprinter: added overflow detection --- ucw/table-types.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ucw/table-types.c b/ucw/table-types.c index 235ceac3..b483ec55 100644 --- a/ucw/table-types.c +++ b/ucw/table-types.c @@ -126,6 +126,12 @@ static const char *xt_size_parse(const char *str, void *dest, struct mempool *po } // FIXME: Detect overflow? + u64 num = xt_size_units[unit_idx].num; + if((parsed && UINT64_MAX / parsed < num) || + (num && UINT64_MAX / num < parsed)) { + return mp_printf(pool, "Size too large: '%s'.", str); + } + *(u64*) dest = parsed * xt_size_units[unit_idx].num; return NULL; } -- 2.39.5