nftables: bump to release 0.4, cleanup our patches
[lede.git] / package / network / utils / nftables / patches / 203-erec-use-stdio-vasprintf-instead-of-gmp_vasprintf.patch
1 From ee23bda1e4a85243fa02dc712f0f323e366dbf8c Mon Sep 17 00:00:00 2001
2 From: Steven Barth <cyrus@openwrt.org>
3 Date: Mon, 15 Dec 2014 14:14:46 +0100
4 Subject: [PATCH 3/5] erec: use stdio vasprintf instead of gmp_vasprintf
5
6 Use stdio's vasprintf instead of gmp_vasprintf which is not part
7 of the mini-gmp function subset. Furthermore convert the only
8 gmp-specific user and allow the compiler to verify format-strings.
9
10 Signed-off-by: Steven Barth <cyrus@openwrt.org>
11 ---
12  src/erec.c     | 6 +++++-
13  src/evaluate.c | 8 ++++++--
14  2 files changed, 11 insertions(+), 3 deletions(-)
15
16 --- a/src/erec.c
17 +++ b/src/erec.c
18 @@ -44,6 +44,7 @@ static void erec_destroy(struct error_re
19         xfree(erec);
20  }
21  
22 +__attribute__((format(printf, 3, 0)))
23  struct error_record *erec_vcreate(enum error_record_types type,
24                                   const struct location *loc,
25                                   const char *fmt, va_list ap)
26 @@ -55,10 +56,13 @@ struct error_record *erec_vcreate(enum e
27         erec->num_locations     = 0;
28         erec_add_location(erec, loc);
29  
30 -       gmp_vasprintf(&erec->msg, fmt, ap);
31 +       if (vasprintf(&erec->msg, fmt, ap) < 0)
32 +               erec->msg = NULL;
33 +
34         return erec;
35  }
36  
37 +__attribute__((format(printf, 3, 4)))
38  struct error_record *erec_create(enum error_record_types type,
39                                  const struct location *loc,
40                                  const char *fmt, ...)
41 --- a/src/evaluate.c
42 +++ b/src/evaluate.c
43 @@ -232,9 +232,13 @@ static int expr_evaluate_value(struct ev
44         case TYPE_INTEGER:
45                 mpz_init_bitmask(mask, ctx->ectx.len);
46                 if (mpz_cmp((*expr)->value, mask) > 0) {
47 +                       char *valstr = mpz_get_str(NULL, 10, (*expr)->value);
48 +                       char *rangestr = mpz_get_str(NULL, 10, mask);
49                         expr_error(ctx->msgs, *expr,
50 -                                  "Value %Zu exceeds valid range 0-%Zu",
51 -                                  (*expr)->value, mask);
52 +                                  "Value %s exceeds valid range 0-%s",
53 +                                  valstr, rangestr);
54 +                       free(valstr);
55 +                       free(rangestr);
56                         mpz_clear(mask);
57                         return -1;
58                 }