~ubuntu-branches/ubuntu/quantal/quagga/quantal

« back to all changes in this revision

Viewing changes to bgpd/bgp_packet.c

  • Committer: Bazaar Package Importer
  • Author(s): Christian Hammers
  • Date: 2010-08-25 00:52:48 UTC
  • mfrom: (1.1.11 upstream) (17.1.5 sid)
  • Revision ID: james.westby@ubuntu.com-20100825005248-ihwizcunu7bzp4fv
Tags: 0.99.17-1
SECURITY:
"This release provides two important bugfixes, which address remote crash
possibility in bgpd discovered by CROSS team.":
1. Stack buffer overflow by processing certain Route-Refresh messages
CVE-2010-2948
2. DoS (crash) while processing certain BGP update AS path messages
CVE-2010-2949
Closes: #594262

Show diffs side-by-side

added added

removed removed

Lines of Context:
2016
2016
 
2017
2017
              while (p_pnt < p_end)
2018
2018
                {
 
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.
 
2022
                   */
 
2023
                  int ok ;
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)
2022
2028
                    {
2023
2029
                      if (BGP_DEBUG (normal, NORMAL))
2025
2031
                      prefix_bgp_orf_remove_all (name);
2026
2032
                      break;
2027
2033
                    }
 
2034
                  ok = ((p_end - p_pnt) >= sizeof(u_int32_t)) ;
 
2035
                  if (ok)
 
2036
                    {
2028
2037
                  memcpy (&seq, p_pnt, sizeof (u_int32_t));
2029
2038
                  p_pnt += sizeof (u_int32_t);
2030
2039
                  orfp.seq = ntohl (seq);
2031
 
                  orfp.ge = *p_pnt++;
2032
 
                  orfp.le = *p_pnt++;
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);
 
2040
                    }
 
2041
                  else
 
2042
                    p_pnt = p_end ;
 
2043
 
 
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  */
 
2051
 
 
2052
                  psize = PSIZE (orfp.p.prefixlen);   /* 0 if not ok          */
 
2053
                  if (psize > prefix_blen(&orfp.p))   /* valid for family ?   */
 
2054
                    {
 
2055
                      ok = 0 ;
 
2056
                      psize = prefix_blen(&orfp.p) ;
 
2057
                    }
 
2058
                  if (psize > (p_end - p_pnt))        /* valid for packet ?   */
 
2059
                    {
 
2060
                      ok = 0 ;
 
2061
                      psize = p_end - p_pnt ;
 
2062
                    }
 
2063
 
 
2064
                  if (psize > 0)
 
2065
                    memcpy (&orfp.p.u.prefix, p_pnt, psize);
2037
2066
                  p_pnt += psize;
2038
2067
 
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",
2041
2070
                               peer->host,
2042
2071
                               (common & ORF_COMMON_PART_REMOVE ? "Remove" : "Add"), 
2043
2072
                               (common & ORF_COMMON_PART_DENY ? "deny" : "permit"),
2044
2073
                               orfp.seq, 
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");
2047
2077
 
 
2078
                  if (ok)
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));
2051
2082
 
2052
 
                  if (ret != CMD_SUCCESS)
 
2083
                  if (!ok || (ret != CMD_SUCCESS))
2053
2084
                    {
2054
2085
                      if (BGP_DEBUG (normal, NORMAL))
2055
2086
                        zlog_debug ("%s Received misformatted prefixlist ORF. Remove All pfxlist", peer->host);