summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/meta.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/meta.c b/src/meta.c
index 87eafeea..34f9ee8e 100644
--- a/src/meta.c
+++ b/src/meta.c
@@ -11,6 +11,7 @@
*/
#include <errno.h>
+#include <limits.h>
#include <stddef.h>
#include <stdlib.h>
#include <stdio.h>
@@ -166,8 +167,18 @@ static struct error_record *ifindex_type_parse(const struct expr *sym,
int ifindex;
ifindex = nft_if_nametoindex(sym->identifier);
- if (ifindex == 0)
- return error(&sym->location, "Interface does not exist");
+ if (ifindex == 0) {
+ char *end;
+ long res;
+
+ errno = 0;
+ res = strtol(sym->identifier, &end, 10);
+
+ if (res < 0 || res > INT_MAX || *end || errno)
+ return error(&sym->location, "Interface does not exist");
+
+ ifindex = (int)res;
+ }
*res = constant_expr_alloc(&sym->location, sym->dtype,
BYTEORDER_HOST_ENDIAN,