ovs-openflowd: Don't segfault when no controllers specified
authorJustin Pettit <jpettit@nicira.com>
Fri, 8 Oct 2010 06:51:02 +0000 (23:51 -0700)
committerJustin Pettit <jpettit@nicira.com>
Fri, 8 Oct 2010 06:51:02 +0000 (23:51 -0700)
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 <derek.cormier@lab.ntt.co.jp>
AUTHORS
utilities/ovs-openflowd.c

diff --git a/AUTHORS b/AUTHORS
index 3d9ddd3..3364fa2 100644 (file)
--- 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
index 945b11d..45333fd 100644 (file)
@@ -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. */