*: Clean up call into inet_aton

In the few places where we were not checking the return code
for inet_aton, do so.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
This commit is contained in:
Donald Sharp 2017-06-13 13:10:32 -04:00
parent 645bb0b10e
commit e6fda497d3
5 changed files with 38 additions and 8 deletions

View File

@ -2151,13 +2151,18 @@ route_set_aggregator_as_compile (const char *arg)
struct aggregator *aggregator;
char as[10];
char address[20];
int ret;
aggregator = XCALLOC (MTYPE_ROUTE_MAP_COMPILED, sizeof (struct aggregator));
sscanf (arg, "%s %s", as, address);
aggregator->as = strtoul (as, NULL, 10);
inet_aton (address, &aggregator->address);
ret = inet_aton (address, &aggregator->address);
if (ret == 0)
{
XFREE (MTYPE_ROUTE_MAP_COMPILED, aggregator);
return NULL;
}
return aggregator;
}

View File

@ -186,7 +186,7 @@ eigrp_new (const char *AS)
eigrp->topology_table = eigrp_topology_new();
eigrp->neighbor_self = eigrp_nbr_new(NULL);
inet_aton("0.0.0.0", &eigrp->neighbor_self->src);
eigrp->neighbor_self->src.s_addr = INADDR_ANY;
eigrp->variance = EIGRP_VARIANCE_DEFAULT;
eigrp->max_paths = EIGRP_MAX_PATHS_DEFAULT;

View File

@ -94,7 +94,12 @@ lsa_delete (struct thread *t)
oclient = THREAD_ARG (t);
inet_aton (args[6], &area_id);
rc = inet_aton (args[6], &area_id);
if (rc <= 0)
{
printf("Address Specified: %s is invalid\n", args[6]);
return rc;
}
printf ("Deleting LSA... ");
rc = ospf_apiclient_lsa_delete (oclient,
@ -123,8 +128,19 @@ lsa_inject (struct thread *t)
cl = THREAD_ARG (t);
inet_aton (args[5], &ifaddr);
inet_aton (args[6], &area_id);
rc = inet_aton (args[5], &ifaddr);
if (rc <= 0)
{
printf ("Ifaddr specified %s is invalid\n", args[5]);
return rc;
}
rc = inet_aton (args[6], &area_id);
if (rc <= 0)
{
printf( "Area ID specified %s is invalid\n", args[6]);
return rc;
}
lsa_type = atoi (args[2]);
opaque_type = atoi (args[3]);
opaque_id = atoi (args[4]);

View File

@ -1192,7 +1192,11 @@ DEFUN (router_info,
/* Check and get Area value if present */
if (area)
{
inet_aton (area, &OspfRI.area_id);
if (!inet_aton (area, &OspfRI.area_id))
{
vty_out (vty, "Please specifya valid Area ID%s", VTY_NEWLINE);
return CMD_WARNING;
}
scope = OSPF_OPAQUE_AREA_LSA;
}
else

View File

@ -48,7 +48,12 @@ zebra_test_ipv4 (int command, int type, char *prefix, char *gateway,
struct in_addr *gpnt;
str2prefix_ipv4 (prefix, &p);
inet_aton (gateway, &gate);
if (!inet_aton (gateway, &gate))
{
printf("Gateway specified: %s is illegal\n", gateway);
return;
}
gpnt = &gate;
api.vrf_id = VRF_DEFAULT;