bgpd: fix Dereference of null pointer in flowspec

a dereference of null pointer exists in current flowspec code, with
prefix pointer. check validity of pointer before going ahead.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
This commit is contained in:
Philippe Guibert 2020-08-21 08:42:20 +02:00
parent 4371bf9110
commit c24ceb896e
2 changed files with 32 additions and 33 deletions

View File

@ -228,10 +228,12 @@ int bgp_flowspec_ip_address(enum bgp_flowspec_util_nlri_t type,
BGP_FLOWSPEC_STRING_DISPLAY_MAX); BGP_FLOWSPEC_STRING_DISPLAY_MAX);
break; break;
case BGP_FLOWSPEC_CONVERT_TO_NON_OPAQUE: case BGP_FLOWSPEC_CONVERT_TO_NON_OPAQUE:
if (prefix) {
if (prefix_local.family == AF_INET) if (prefix_local.family == AF_INET)
PREFIX_COPY_IPV4(prefix, &prefix_local) PREFIX_COPY_IPV4(prefix, &prefix_local)
else else
PREFIX_COPY_IPV6(prefix, &prefix_local) PREFIX_COPY_IPV6(prefix, &prefix_local)
}
break; break;
case BGP_FLOWSPEC_VALIDATE_ONLY: case BGP_FLOWSPEC_VALIDATE_ONLY:
default: default:

View File

@ -274,9 +274,7 @@ void route_vty_out_flowspec(struct vty *vty, const struct prefix *p,
dest = path->net; dest = path->net;
if (dest) if (dest)
bgp_dest_get_bgp_table_info(dest); bgp_dest_get_bgp_table_info(dest);
/* Print prefix */ if (p == NULL || p->family != AF_FLOWSPEC)
if (p != NULL) {
if (p->family != AF_FLOWSPEC)
return; return;
if (json_paths) { if (json_paths) {
if (display == NLRI_STRING_FORMAT_JSON) if (display == NLRI_STRING_FORMAT_JSON)
@ -303,7 +301,6 @@ void route_vty_out_flowspec(struct vty *vty, const struct prefix *p,
vty_out(vty, " %-30s", return_string); vty_out(vty, " %-30s", return_string);
else if (json_paths && display == NLRI_STRING_FORMAT_JSON) else if (json_paths && display == NLRI_STRING_FORMAT_JSON)
json_object_array_add(json_paths, json_nlri_path); json_object_array_add(json_paths, json_nlri_path);
}
if (!path) if (!path)
return; return;
if (path->attr && if (path->attr &&