summaryrefslogtreecommitdiffstats
path: root/package/network/utils/nftables/patches/202-datatype-use-mpz_set_str-instead-of-gmp_sscanf.patch
blob: 4b22ec26e55c81c744e386dffc1ed888986db5a0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
From 23e8958a5e539f682be4cbdf5196aa2014c7e295 Mon Sep 17 00:00:00 2001
From: Steven Barth <cyrus@openwrt.org>
Date: Mon, 15 Dec 2014 14:09:27 +0100
Subject: [PATCH 2/5] datatype: use mpz_set_str instead of gmp_sscanf

This simplifies the integer parsing logic and restricts it to
functions being part of the mini-gmp subset.

Signed-off-by: Steven Barth <cyrus@openwrt.org>
---
 src/datatype.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

--- a/src/datatype.c
+++ b/src/datatype.c
@@ -275,11 +275,9 @@ static struct error_record *integer_type
 					       struct expr **res)
 {
 	mpz_t v;
-	int len;
 
 	mpz_init(v);
-	if (gmp_sscanf(sym->identifier, "%Zu%n", v, &len) != 1 ||
-	    (int)strlen(sym->identifier) != len) {
+	if (mpz_set_str(v, sym->identifier, 0)) {
 		mpz_clear(v);
 		return error(&sym->location, "Could not parse %s",
 			     sym->dtype->desc);