diff options
author | brian <brian@cvs.openbsd.org> | 2000-08-30 22:04:36 +0000 |
---|---|---|
committer | brian <brian@cvs.openbsd.org> | 2000-08-30 22:04:36 +0000 |
commit | 16f441cd668671b8e38c807ffcc3bd17c0609e58 (patch) | |
tree | 3d2d2f6a3d3e7b0588fe41a9b2c3fb03b072b626 /usr.sbin | |
parent | 9d12b18c0689cf8efe46f3bbd0864b8560257de6 (diff) |
Complain about invalid arguments passed to ``set ifaddr''
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/ppp/ppp/command.c | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/usr.sbin/ppp/ppp/command.c b/usr.sbin/ppp/ppp/command.c index 8723c7da216..846dc7eb411 100644 --- a/usr.sbin/ppp/ppp/command.c +++ b/usr.sbin/ppp/ppp/command.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $OpenBSD: command.c,v 1.50 2000/08/18 00:02:10 brian Exp $ + * $OpenBSD: command.c,v 1.51 2000/08/30 22:04:35 brian Exp $ * */ #include <sys/param.h> @@ -2108,8 +2108,14 @@ AddCommand(struct cmdargs const *arg) } else if (strcasecmp(arg->argv[arg->argn], "DNS1") == 0) { addrs = ROUTE_DSTDNS1; dest = arg->bundle->ncp.ipcp.ns.dns[1]; - } else + } else { dest = GetIpAddr(arg->argv[arg->argn]); + if (dest.s_addr == INADDR_NONE) { + log_Printf(LogWARN, "%s: Invalid destination address\n", + arg->argv[arg->argn]); + return -1; + } + } netmask = GetIpAddr(arg->argv[arg->argn+1]); gw = 2; } @@ -2117,8 +2123,14 @@ AddCommand(struct cmdargs const *arg) if (strcasecmp(arg->argv[arg->argn+gw], "HISADDR") == 0) { gateway = arg->bundle->ncp.ipcp.peer_ip; addrs |= ROUTE_GWHISADDR; - } else + } else { gateway = GetIpAddr(arg->argv[arg->argn+gw]); + if (gateway.s_addr == INADDR_NONE) { + log_Printf(LogWARN, "%s: Invalid gateway address\n", + arg->argv[arg->argn + gw]); + return -1; + } + } if (bundle_SetRoute(arg->bundle, RTM_ADD, dest, gateway, netmask, arg->cmd->args ? 1 : 0, (addrs & ROUTE_GWHISADDR) ? 1 : 0) |