info: add sanitation of the configuration
authorFerry Huberts <ferry.huberts@pelagic.nl>
Wed, 4 Jan 2017 07:45:33 +0000 (08:45 +0100)
committerFerry Huberts <ferry.huberts@pelagic.nl>
Wed, 4 Jan 2017 08:47:11 +0000 (09:47 +0100)
Signed-off-by: Ferry Huberts <ferry.huberts@pelagic.nl>
lib/info/olsrd_info.c

index 1d49e83..3dffbdd 100644 (file)
@@ -1035,6 +1035,12 @@ static int plugin_ipc_init(void) {
   return 0;
 }
 
+static void info_sanitise_config(info_plugin_config_t *cfg) {
+  if (cfg->ipc_port < 1) {
+    cfg->ipc_port = 1;
+  }
+}
+
 int info_plugin_init(const char * plugin_name, info_plugin_functions_t *plugin_functions, info_plugin_config_t *plugin_config) {
   int i;
 
@@ -1046,6 +1052,8 @@ int info_plugin_init(const char * plugin_name, info_plugin_functions_t *plugin_f
   functions = plugin_functions;
   config = plugin_config;
 
+  info_sanitise_config(config);
+
   memset(&outbuffer, 0, sizeof(outbuffer));
   for (i = 0; i < MAX_CLIENTS; ++i) {
     outbuffer.socket[i] = -1;