summaryrefslogtreecommitdiff
path: root/sbin/ipsecadm
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>1999-06-05 17:05:35 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>1999-06-05 17:05:35 +0000
commit97225cea46148f9eb52f3b752fa13427dd50e89d (patch)
treeb2dd7ce2e89a7e8602b9a9dbcbb1ffec64ee7020 /sbin/ipsecadm
parent02ab8469fbb85ab1adaa89a65e4a4e3e5a09a69a (diff)
use inet_aton()
Diffstat (limited to 'sbin/ipsecadm')
-rw-r--r--sbin/ipsecadm/ipsecadm.c37
1 files changed, 31 insertions, 6 deletions
diff --git a/sbin/ipsecadm/ipsecadm.c b/sbin/ipsecadm/ipsecadm.c
index 21615834926..8e9af4c7191 100644
--- a/sbin/ipsecadm/ipsecadm.c
+++ b/sbin/ipsecadm/ipsecadm.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ipsecadm.c,v 1.17 1999/04/18 15:06:58 provos Exp $ */
+/* $OpenBSD: ipsecadm.c,v 1.18 1999/06/05 17:05:34 deraadt Exp $ */
/*
* The authors of this code are John Ioannidis (ji@tla.org),
* Angelos D. Keromytis (kermit@csd.uch.gr) and
@@ -511,7 +511,12 @@ main(int argc, char **argv)
{
proxy.sin.sin_family = AF_INET;
proxy.sin.sin_len = sizeof(struct sockaddr_in);
- proxy.sin.sin_addr.s_addr = inet_addr(argv[i + 1]);
+ if (!inet_aton(argv[i + 1], &proxy.sin.sin_addr)) {
+ fprintf(stderr,
+ "%s: Warning: proxy address %s is not valid\n",
+ argv[i + 1]);
+ exit(1);
+ }
sad3.sadb_address_exttype = SADB_EXT_ADDRESS_PROXY;
sad3.sadb_address_len = 1 + sizeof(struct sockaddr_in) / 8;
i++;
@@ -589,10 +594,30 @@ main(int argc, char **argv)
osmask.sin.sin_len = sizeof(struct sockaddr_in);
odmask.sin.sin_len = sizeof(struct sockaddr_in);
- osrc.sin.sin_addr.s_addr = inet_addr(argv[i + 1]); i++;
- osmask.sin.sin_addr.s_addr = inet_addr(argv[i + 1]); i++;
- odst.sin.sin_addr.s_addr = inet_addr(argv[i + 1]); i++;
- odmask.sin.sin_addr.s_addr = inet_addr(argv[i + 1]); i++;
+ if (!inet_aton(argv[i + 1], &osrc.sin.sin_addr)) {
+ fprintf(stderr, "%s: source address %s is not valid\n", argv[0],
+ argv[i + 1]);
+ exit(1);
+ }
+ i++;
+ if (!inet_aton(argv[i + 1], &osmask.sin.sin_addr)) {
+ fprintf(stderr, "%s: source netmask %s is not valid\n", argv[0],
+ argv[i + 1]);
+ exit(1);
+ }
+ i++;
+ if (!inet_aton(argv[i + 1], &odst.sin.sin_addr)) {
+ fprintf(stderr, "%s: destination address %s is not valid\n", argv[0],
+ argv[i + 1]);
+ exit(1);
+ }
+ i++;
+ if (!inet_aton(argv[i + 1], &odmask.sin.sin_addr)) {
+ fprintf(stderr, "%s: destination netmask %s is not valid\n", argv[0],
+ argv[i + 1]);
+ exit(1);
+ }
+ i++;
continue;
}