summaryrefslogtreecommitdiff
path: root/lib/zclient.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/zclient.c')
-rw-r--r--lib/zclient.c22
1 files changed, 14 insertions, 8 deletions
diff --git a/lib/zclient.c b/lib/zclient.c
index f16c94369b..20c285cf7f 100644
--- a/lib/zclient.c
+++ b/lib/zclient.c
@@ -996,17 +996,24 @@ done:
return ret;
}
-int zapi_nhg_encode(struct stream *s, int cmd, struct zapi_nhg *api_nhg)
+static int zapi_nhg_encode(struct stream *s, int cmd, struct zapi_nhg *api_nhg)
{
int i;
if (cmd != ZEBRA_NHG_DEL && cmd != ZEBRA_NHG_ADD) {
flog_err(EC_LIB_ZAPI_ENCODE,
- "%s: Specified zapi NHG command (%d) doesn't exist\n",
+ "%s: Specified zapi NHG command (%d) doesn't exist",
__func__, cmd);
return -1;
}
+ if (api_nhg->nexthop_num >= MULTIPATH_NUM ||
+ api_nhg->backup_nexthop_num >= MULTIPATH_NUM) {
+ flog_err(EC_LIB_ZAPI_ENCODE,
+ "%s: zapi NHG encode with invalid input", __func__);
+ return -1;
+ }
+
stream_reset(s);
zclient_create_header(s, cmd, VRF_DEFAULT);
@@ -1024,7 +1031,6 @@ int zapi_nhg_encode(struct stream *s, int cmd, struct zapi_nhg *api_nhg)
zapi_nexthop_encode(s, &api_nhg->nexthops[i], 0, 0);
/* Backup nexthops */
-
stream_putw(s, api_nhg->backup_nexthop_num);
for (i = 0; i < api_nhg->backup_nexthop_num; i++)
@@ -1059,7 +1065,7 @@ int zapi_route_encode(uint8_t cmd, struct stream *s, struct zapi_route *api)
if (api->type >= ZEBRA_ROUTE_MAX) {
flog_err(EC_LIB_ZAPI_ENCODE,
- "%s: Specified route type (%u) is not a legal value\n",
+ "%s: Specified route type (%u) is not a legal value",
__func__, api->type);
return -1;
}
@@ -1071,7 +1077,7 @@ int zapi_route_encode(uint8_t cmd, struct stream *s, struct zapi_route *api)
if (api->safi < SAFI_UNICAST || api->safi >= SAFI_MAX) {
flog_err(EC_LIB_ZAPI_ENCODE,
- "%s: Specified route SAFI (%u) is not a legal value\n",
+ "%s: Specified route SAFI (%u) is not a legal value",
__func__, api->safi);
return -1;
}
@@ -1286,7 +1292,7 @@ int zapi_route_decode(struct stream *s, struct zapi_route *api)
STREAM_GETC(s, api->type);
if (api->type >= ZEBRA_ROUTE_MAX) {
flog_err(EC_LIB_ZAPI_ENCODE,
- "%s: Specified route type: %d is not a legal value\n",
+ "%s: Specified route type: %d is not a legal value",
__func__, api->type);
return -1;
}
@@ -1297,7 +1303,7 @@ int zapi_route_decode(struct stream *s, struct zapi_route *api)
STREAM_GETC(s, api->safi);
if (api->safi < SAFI_UNICAST || api->safi >= SAFI_MAX) {
flog_err(EC_LIB_ZAPI_ENCODE,
- "%s: Specified route SAFI (%u) is not a legal value\n",
+ "%s: Specified route SAFI (%u) is not a legal value",
__func__, api->safi);
return -1;
}
@@ -3298,7 +3304,7 @@ static void zclient_capability_decode(ZAPI_CALLBACK_ARGS)
if (vrf_backend < 0 || vrf_configure_backend(vrf_backend)) {
flog_err(EC_LIB_ZAPI_ENCODE,
- "%s: Garbage VRF backend type: %d\n", __func__,
+ "%s: Garbage VRF backend type: %d", __func__,
vrf_backend);
goto stream_failure;
}