From c5cd8b2ef14fa258f57ac5046ca3e85d97cd7650 Mon Sep 17 00:00:00 2001 From: Justin Pettit Date: Thu, 7 Oct 2010 23:51:02 -0700 Subject: [PATCH] ovs-openflowd: Don't segfault when no controllers specified If no controllers are specified on the command-line, ovs-openflowd adds a couple of its own. The code that accounts for the controllers correctly allocated space for them, but used the command-line count to determine how many to set. This led to a segfault when later code tried to dereference them. Reported-by: Derek Cormier --- AUTHORS | 1 + utilities/ovs-openflowd.c | 8 +++----- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/AUTHORS b/AUTHORS index 3d9ddd33..3364fa2b 100644 --- a/AUTHORS +++ b/AUTHORS @@ -39,6 +39,7 @@ Brad Hall brad@nicira.com Brandon Heller brandonh@stanford.edu Bryan Fulton bryan@nicira.com Cedric Hobbs cedric@nicira.com +Derek Cormier derek.cormier@lab.ntt.co.jp Ghanem Bahri bahri.ghanem@gmail.com Henrik Amren henrik@nicira.com Jad Naous jnaous@gmail.com diff --git a/utilities/ovs-openflowd.c b/utilities/ovs-openflowd.c index 945b11d0..45333fd1 100644 --- a/utilities/ovs-openflowd.c +++ b/utilities/ovs-openflowd.c @@ -457,11 +457,9 @@ parse_options(int argc, char *argv[], struct ofsettings *s) /* Set up controllers. */ s->n_controllers = controllers.n; s->controllers = xmalloc(s->n_controllers * sizeof *s->controllers); - if (argc > 1) { - for (i = 0; i < s->n_controllers; i++) { - s->controllers[i] = controller_opts; - s->controllers[i].target = controllers.names[i]; - } + for (i = 0; i < s->n_controllers; i++) { + s->controllers[i] = controller_opts; + s->controllers[i].target = controllers.names[i]; } /* Sanity check. */ -- 2.30.2