[PATCH 5/7] libxt_devgroup: guard against negative numbers

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



More corrections of the strtoul kind.

Signed-off-by: Jan Engelhardt <jengelh@xxxxxxx>
---
 extensions/libxt_devgroup.c |   10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/extensions/libxt_devgroup.c b/extensions/libxt_devgroup.c
index 69ae279..4a69c82 100644
--- a/extensions/libxt_devgroup.c
+++ b/extensions/libxt_devgroup.c
@@ -46,14 +46,16 @@ static void devgroup_parse_groupspec(const char *arg, unsigned int *group,
 				     unsigned int *mask)
 {
 	char *end;
+	bool ok;
 
-	*group = strtoul(arg, &end, 0);
-	if (end != arg && (*end == '/' || *end == '\0')) {
+	ok = xtables_strtoui(arg, &end, group, 0, UINT32_MAX);
+	if (ok && (*end == '/' || *end == '\0')) {
 		if (*end == '/')
-			*mask = strtoul(end + 1, &end, 0);
+			ok = xtables_strtoui(end + 1, NULL, mask,
+			                     0, UINT32_MAX);
 		else
 			*mask = ~0U;
-		if (*end != '\0' || end == arg)
+		if (!ok)
 			xtables_error(PARAMETER_PROBLEM,
 				      "Bad group value \"%s\"", arg);
 	} else {
-- 
1.7.7

--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Netfitler Users]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux