2017
2017
while (p_pnt < p_end)
2019
/* If the ORF entry is malformed, want to read as much of it
2020
* as possible without going beyond the bounds of the entry,
2021
* to maximise debug information.
2019
2024
memset (&orfp, 0, sizeof (struct orf_prefix));
2020
2025
common = *p_pnt++;
2026
/* after ++: p_pnt <= p_end */
2021
2027
if (common & ORF_COMMON_PART_REMOVE_ALL)
2023
2029
if (BGP_DEBUG (normal, NORMAL))
2025
2031
prefix_bgp_orf_remove_all (name);
2034
ok = ((p_end - p_pnt) >= sizeof(u_int32_t)) ;
2028
2037
memcpy (&seq, p_pnt, sizeof (u_int32_t));
2029
2038
p_pnt += sizeof (u_int32_t);
2030
2039
orfp.seq = ntohl (seq);
2033
orfp.p.prefixlen = *p_pnt++;
2034
orfp.p.family = afi2family (afi);
2035
psize = PSIZE (orfp.p.prefixlen);
2036
memcpy (&orfp.p.u.prefix, p_pnt, psize);
2044
if ((ok = (p_pnt < p_end)))
2045
orfp.ge = *p_pnt++ ; /* value checked in prefix_bgp_orf_set() */
2046
if ((ok = (p_pnt < p_end)))
2047
orfp.le = *p_pnt++ ; /* value checked in prefix_bgp_orf_set() */
2048
if ((ok = (p_pnt < p_end)))
2049
orfp.p.prefixlen = *p_pnt++ ;
2050
orfp.p.family = afi2family (afi); /* afi checked already */
2052
psize = PSIZE (orfp.p.prefixlen); /* 0 if not ok */
2053
if (psize > prefix_blen(&orfp.p)) /* valid for family ? */
2056
psize = prefix_blen(&orfp.p) ;
2058
if (psize > (p_end - p_pnt)) /* valid for packet ? */
2061
psize = p_end - p_pnt ;
2065
memcpy (&orfp.p.u.prefix, p_pnt, psize);
2037
2066
p_pnt += psize;
2039
2068
if (BGP_DEBUG (normal, NORMAL))
2040
zlog_debug ("%s rcvd %s %s seq %u %s/%d ge %d le %d",
2069
zlog_debug ("%s rcvd %s %s seq %u %s/%d ge %d le %d%s",
2042
2071
(common & ORF_COMMON_PART_REMOVE ? "Remove" : "Add"),
2043
2072
(common & ORF_COMMON_PART_DENY ? "deny" : "permit"),
2045
2074
inet_ntop (orfp.p.family, &orfp.p.u.prefix, buf, BUFSIZ),
2046
orfp.p.prefixlen, orfp.ge, orfp.le);
2075
orfp.p.prefixlen, orfp.ge, orfp.le,
2076
ok ? "" : " MALFORMED");
2048
2079
ret = prefix_bgp_orf_set (name, afi, &orfp,
2049
2080
(common & ORF_COMMON_PART_DENY ? 0 : 1 ),
2050
2081
(common & ORF_COMMON_PART_REMOVE ? 0 : 1));
2052
if (ret != CMD_SUCCESS)
2083
if (!ok || (ret != CMD_SUCCESS))
2054
2085
if (BGP_DEBUG (normal, NORMAL))
2055
2086
zlog_debug ("%s Received misformatted prefixlist ORF. Remove All pfxlist", peer->host);