diff options
| author | Donald Sharp <donaldsharp72@gmail.com> | 2023-08-19 16:17:14 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-08-19 16:17:14 -0400 |
| commit | 899427b5150b19b4f950e2ef3b70c7089c45f6ff (patch) | |
| tree | 4384fc7bbacbe6e1c9575f96f21ea91999d8bbb1 /pbrd/pbr_vty.c | |
| parent | fa8e49c79e0af641959c8a0aaeac8c1fc0d6315c (diff) | |
| parent | 5cde1e89f06b8a8795f694b5c9ee7b78cd0b50f0 (diff) | |
Merge pull request #14216 from LabNConsulting/ziemba-coverity-pbr-230816
pbrd: address coverity issues reported 230815
Diffstat (limited to 'pbrd/pbr_vty.c')
| -rw-r--r-- | pbrd/pbr_vty.c | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/pbrd/pbr_vty.c b/pbrd/pbr_vty.c index 0d6e1afd5b..3dbb0b958b 100644 --- a/pbrd/pbr_vty.c +++ b/pbrd/pbr_vty.c @@ -441,18 +441,18 @@ DEFPY (pbr_map_match_dscp, } unsigned long ul_dscp; - char *pend; + char *pend = NULL; uint8_t raw_dscp; assert(dscp); - ul_dscp = strtol(dscp, &pend, 0); - if (*pend) + ul_dscp = strtoul(dscp, &pend, 0); + if (pend && *pend) raw_dscp = pbr_map_decode_dscp_enum(dscp); else raw_dscp = ul_dscp << 2; if (raw_dscp > PBR_DSFIELD_DSCP) { vty_out(vty, "Invalid dscp value: %s%s\n", dscp, - (pend ? "" : " (numeric value must be in range 0-63)")); + ((pend && *pend) ? "" : " (numeric value must be in range 0-63)")); return CMD_WARNING_CONFIG_FAILED; } @@ -790,6 +790,9 @@ DEFPY (pbr_map_action_src_port, /* clang-format on */ struct pbr_map_sequence *pbrms = VTY_GET_CONTEXT(pbr_map_sequence); + if (!pbrms) + return CMD_WARNING_CONFIG_FAILED; + if (no) { if (!CHECK_FLAG(pbrms->action_bm, PBR_ACTION_SRC_PORT)) return CMD_SUCCESS; @@ -821,6 +824,9 @@ DEFPY (pbr_map_action_dst_port, /* clang-format on */ struct pbr_map_sequence *pbrms = VTY_GET_CONTEXT(pbr_map_sequence); + if (!pbrms) + return CMD_WARNING_CONFIG_FAILED; + if (no) { if (!CHECK_FLAG(pbrms->action_bm, PBR_ACTION_DST_PORT)) return CMD_SUCCESS; @@ -851,6 +857,9 @@ DEFPY (pbr_map_action_dscp, /* clang-format on */ struct pbr_map_sequence *pbrms = VTY_GET_CONTEXT(pbr_map_sequence); + if (!pbrms) + return CMD_WARNING_CONFIG_FAILED; + if (no) { if (!CHECK_FLAG(pbrms->action_bm, PBR_ACTION_DSCP)) return CMD_SUCCESS; @@ -859,19 +868,19 @@ DEFPY (pbr_map_action_dscp, } unsigned long ul_dscp; - char *pend; + char *pend = NULL; uint8_t raw_dscp; assert(dscp); - ul_dscp = strtol(dscp, &pend, 0); - if (*pend) + ul_dscp = strtoul(dscp, &pend, 0); + if (pend && *pend) raw_dscp = pbr_map_decode_dscp_enum(dscp); else raw_dscp = ul_dscp << 2; if (raw_dscp > PBR_DSFIELD_DSCP) { vty_out(vty, "Invalid dscp value: %s%s\n", dscp, - (pend ? "" : " (numeric value must be in range 0-63)")); + ((pend && *pend) ? "" : " (numeric value must be in range 0-63)")); return CMD_WARNING_CONFIG_FAILED; } if (CHECK_FLAG(pbrms->action_bm, PBR_ACTION_DSCP) && @@ -898,6 +907,9 @@ DEFPY (pbr_map_action_ecn, /* clang-format on */ struct pbr_map_sequence *pbrms = VTY_GET_CONTEXT(pbr_map_sequence); + if (!pbrms) + return CMD_WARNING_CONFIG_FAILED; + if (no) { if (!CHECK_FLAG(pbrms->action_bm, PBR_ACTION_ECN)) return CMD_SUCCESS; @@ -1342,6 +1354,7 @@ DEFPY(pbr_map_vrf, pbr_map_vrf_cmd, * If an equivalent set vrf * exists, just return success. */ if ((pbrms->forwarding_type == PBR_FT_SETVRF) && + vrf_name && strncmp(pbrms->vrf_name, vrf_name, sizeof(pbrms->vrf_name)) == 0) return CMD_SUCCESS; else if (!vrf_name && (pbrms->forwarding_type == PBR_FT_VRF_UNCHANGED)) |
