getdata: increase max number of shared networks
authorSami Kerola <kerolasa@iki.fi>
Tue, 5 Apr 2011 19:10:46 +0000 (21:10 +0200)
committerSami Kerola <kerolasa@iki.fi>
Tue, 5 Apr 2011 19:10:46 +0000 (21:10 +0200)
Anders & Thor Eivind reported dhcpd-pools to mess console and
crash at the end of execution. Reason was missing boundary check.
The fix this time is more of less just a increase to max numbers.
That will work ot some extent.

The memory allocations has to be made fully dynamic, but that is
a little bit difficult with the way default.h and parse_config
are working. Basically problem is globals gone crazy & re-entrant
issue with parse function. The true fix to the issue will have to
wait for complete redesign of internals of the command.

Reported-by: Anders LĂ„stad <ala@nextgentel.com>
Reported-by: Thor Eivind Brantzeg <tbr@nextgentel.com>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>

src/defaults.h
src/getdata.c

index 3115751..c34e4be 100644 (file)
 static const int MAXLEN = 1024;
 
 /* Total number of characters in all shared network names */
-static const int SHARED_NETWORKS_NAMES = 24576;
+static const int SHARED_NETWORKS_NAMES = 65536;
 
 /* Maximum number of shared networks */
-static const int SHARED_NETWORKS = 1024;
+static const int SHARED_NETWORKS = 8192;
 
 /* Maximum number of ranges */
 static const unsigned int RANGES = 65536;
index c25d87e..c57d2c7 100644 (file)
@@ -388,7 +388,7 @@ char *parse_config(int is_include, char *config_file,
                                num_ranges++;
                                if (RANGES < num_ranges) {
                                        errx(EXIT_FAILURE,
-                                            "parse_config: Range space full! Increase RANGES and recompile.");
+                                            "parse_config: increase default.h RANGES and recompile.");
                                }
                                newclause = true;
                                break;
@@ -427,8 +427,15 @@ char *parse_config(int is_include, char *config_file,
                                         * away by reallocationg
                                         * more space. */
                                        errx(EXIT_FAILURE,
-                                            "parse_config: End of shared-network space, increase SHARED_NETWORKS_NAMES and recompile");
+                                            "parse_config: increase default.h SHARED_NETWORKS_NAMES and recompile");
                                }
+                               if (SHARED_NETWORKS < num_shared_networks) {
+                                       /* FIXME: make this go
+                                        * away by reallocationg
+                                        * more space. */
+                                       errx(EXIT_FAILURE,
+                                            "parse_config: increase default.h SHARED_NETWORKS and recompile");
+                                }
                                argument = 0;
                                braces_shared = braces;
                                break;