[quagga-dev,15443] bgpd: fix potential crash in community_list_dup_check

Message ID 1465244535-3515-1-git-send-email-chris@opensourcerouting.org
State Under Review
Headers show

Commit Message

Christian Franke June 6, 2016, 8:22 p.m.
From: Christian Franke <nobody@nowhere.ws>

extcommunity_list_set may set the ->config for an entry
to NULL. In this case, the old code in community_list_dup_check
would cause a NULL pointer dereference.

Adjust the code so it behaves the same in the absence of NULL
pointers and otherwise checks if both are NULL to determine
equality.

Signed-off-by: Christian Franke <chris@opensourcerouting.org>
---
 bgpd/bgp_clist.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

cisystem@netdef.org June 6, 2016, 9:40 p.m. | #1
Continous Integration Result: SUCCESSFUL

Congratulations, this patch passed basic tests

Tested-by: NetDEF CI System <cisystem@netdef.org>

This is an EXPERIMENTAL automated CI system.
For questions and feedback, feel free to email
Martin Winter <mwinter@opensourcerouting.org>.

Patches applied :
  Patchwork 1959: http://patchwork.quagga.net/patch/1959
       [quagga-dev,15443] bgpd: fix potential crash in community_list_dup_check
Tested on top of Git : 86c5d2e (as of 20160315.231717 UTC)
CI System Testrun URL: https://ci1.netdef.org/browse/QUAGGA-QPWORK-300/


Regards,
  NetDEF/OpenSourceRouting Continous Integration (CI) System

---
OpenSourceRouting.org is a project of the Network Device Education Foundation,
For more information, see www.netdef.org and www.opensourcerouting.org
For questions in regards to this CI System, contact Martin Winter, mwinter@netdef.org
Donald Sharp June 7, 2016, 2:21 a.m. | #2
Acked-by: Donald Sharp <sharpd@cumulusnetworks.com>

On Mon, Jun 6, 2016 at 4:22 PM, Christian Franke <
chris@opensourcerouting.org> wrote:

> From: Christian Franke <nobody@nowhere.ws>
>
> extcommunity_list_set may set the ->config for an entry
> to NULL. In this case, the old code in community_list_dup_check
> would cause a NULL pointer dereference.
>
> Adjust the code so it behaves the same in the absence of NULL
> pointers and otherwise checks if both are NULL to determine
> equality.
>
> Signed-off-by: Christian Franke <chris@opensourcerouting.org>
> ---
>  bgpd/bgp_clist.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/bgpd/bgp_clist.c b/bgpd/bgp_clist.c
> index bb06028..1f1a4e7 100644
> --- a/bgpd/bgp_clist.c
> +++ b/bgpd/bgp_clist.c
> @@ -644,7 +644,10 @@ community_list_dup_check (struct community_list *list,
>            break;
>          case COMMUNITY_LIST_EXPANDED:
>          case EXTCOMMUNITY_LIST_EXPANDED:
> -          if (strcmp (entry->config, new->config) == 0)
> +          if (entry->config && new->config
> +              && strcmp (entry->config, new->config) == 0)
> +            return 1;
> +          if (!entry->config && !new->config)
>              return 1;
>            break;
>          default:
> --
> 2.8.0
>
>
> _______________________________________________
> Quagga-dev mailing list
> Quagga-dev@lists.quagga.net
> https://lists.quagga.net/mailman/listinfo/quagga-dev
>

Patch hide | download patch | download mbox

diff --git a/bgpd/bgp_clist.c b/bgpd/bgp_clist.c
index bb06028..1f1a4e7 100644
--- a/bgpd/bgp_clist.c
+++ b/bgpd/bgp_clist.c
@@ -644,7 +644,10 @@  community_list_dup_check (struct community_list *list,
           break;
         case COMMUNITY_LIST_EXPANDED:
         case EXTCOMMUNITY_LIST_EXPANDED:
-          if (strcmp (entry->config, new->config) == 0)
+          if (entry->config && new->config
+              && strcmp (entry->config, new->config) == 0)
+            return 1;
+          if (!entry->config && !new->config)
             return 1;
           break;
         default: