aboutsummaryrefslogtreecommitdiff
path: root/sbin/ipfw/nat.c
diff options
context:
space:
mode:
authorAndrey V. Elsukov <ae@FreeBSD.org>2011-06-14 13:02:26 +0000
committerAndrey V. Elsukov <ae@FreeBSD.org>2011-06-14 13:02:26 +0000
commit980ccceb94452d5700cbe5b129185576f19b135a (patch)
treec628e85711a1edf224273dd7a8f665b893fc0e41 /sbin/ipfw/nat.c
parentc9d658e9f7ea84b09d07d805589de6f7e9b0fc59 (diff)
downloadsrc-980ccceb94452d5700cbe5b129185576f19b135a.tar.gz
src-980ccceb94452d5700cbe5b129185576f19b135a.zip
Check nat id a bit more strictly.
Notes
Notes: svn path=/head/; revision=223079
Diffstat (limited to 'sbin/ipfw/nat.c')
-rw-r--r--sbin/ipfw/nat.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/sbin/ipfw/nat.c b/sbin/ipfw/nat.c
index 0331d3836598..e91c6ec29161 100644
--- a/sbin/ipfw/nat.c
+++ b/sbin/ipfw/nat.c
@@ -721,16 +721,18 @@ ipfw_config_nat(int ac, char **av)
{
struct cfg_nat *n; /* Nat instance configuration. */
int i, off, tok, ac1;
- char *id, *buf, **av1;
+ char *id, *buf, **av1, *end;
size_t len;
av++; ac--;
/* Nat id. */
- if (ac && isdigit(**av)) {
- id = *av;
- ac--; av++;
- } else
+ if (ac == 0)
errx(EX_DATAERR, "missing nat id");
+ id = *av;
+ i = (int)strtol(id, &end, 0);
+ if (i <= 0 || *end != '\0')
+ errx(EX_DATAERR, "illegal nat id: %s", id);
+ av++; ac--;
if (ac == 0)
errx(EX_DATAERR, "missing option");
@@ -787,7 +789,6 @@ ipfw_config_nat(int ac, char **av)
off = sizeof(*n);
memset(buf, 0, len);
n = (struct cfg_nat *)buf;
- i = atoi(id);
n->id = i;
while (ac > 0) {