From e6fda497d36365ef9b5adcbb9f59c397d0c7f5c5 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Tue, 13 Jun 2017 13:10:32 -0400 Subject: [PATCH] *: 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 --- bgpd/bgp_routemap.c | 9 +++++++-- eigrpd/eigrpd.c | 2 +- ospfclient/ospfclient.c | 22 +++++++++++++++++++--- ospfd/ospf_ri.c | 6 +++++- zebra/client_main.c | 7 ++++++- 5 files changed, 38 insertions(+), 8 deletions(-) diff --git a/bgpd/bgp_routemap.c b/bgpd/bgp_routemap.c index 6c6b622626..3cf0d84684 100644 --- a/bgpd/bgp_routemap.c +++ b/bgpd/bgp_routemap.c @@ -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; } diff --git a/eigrpd/eigrpd.c b/eigrpd/eigrpd.c index 93a69b776b..a0ead05224 100644 --- a/eigrpd/eigrpd.c +++ b/eigrpd/eigrpd.c @@ -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; diff --git a/ospfclient/ospfclient.c b/ospfclient/ospfclient.c index 195fd5b5a0..d8d0fe8d47 100644 --- a/ospfclient/ospfclient.c +++ b/ospfclient/ospfclient.c @@ -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]); diff --git a/ospfd/ospf_ri.c b/ospfd/ospf_ri.c index 4723f4a919..bd2506d2d4 100644 --- a/ospfd/ospf_ri.c +++ b/ospfd/ospf_ri.c @@ -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 diff --git a/zebra/client_main.c b/zebra/client_main.c index c9d738bb08..0e77ea4aec 100644 --- a/zebra/client_main.c +++ b/zebra/client_main.c @@ -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; -- 2.39.5