From 23e8774c4487f1deabdff6d9df76bf9125745f41 Mon Sep 17 00:00:00 2001 From: Camille Chauvet Date: Wed, 19 Apr 2023 13:51:57 +0000 Subject: [PATCH] fix: check argument overflow --- utils/ft_isnum.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/utils/ft_isnum.c b/utils/ft_isnum.c index f78e9ad..298b91e 100644 --- a/utils/ft_isnum.c +++ b/utils/ft_isnum.c @@ -6,21 +6,28 @@ /* By: cchauvet +#include bool ft_isnum(char str[]) { size_t i; + size_t num; + num = 0; i = 0; while (str[i] != '\0') { if (str[i] > '9' || str[i] < '0') return (0); + num = num * 10 + str[i] - 48; + if (num > INT_MAX) + return (0); i++; } return (1);