]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
datatype: use mpz_set_str instead of gmp_sscanf
authorSteven Barth <cyrus@openwrt.org>
Tue, 6 Jan 2015 22:40:23 +0000 (23:40 +0100)
committerPablo Neira Ayuso <pablo@netfilter.org>
Wed, 7 Jan 2015 12:08:41 +0000 (13:08 +0100)
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>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
src/datatype.c

index 2a9fcdb0f37043defa0aeaa3cf8d80640dab7064..76f2af13820682e286814bd189a4f1a82fe17b6b 100644 (file)
@@ -276,11 +276,9 @@ static struct error_record *integer_type_parse(const struct expr *sym,
                                               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);