fixed possible crash in hostserv module
[srvx.git] / src / mod-hostserv.c
index 8829c66403fffca7938529633402923f4d20b642..845382f6a63c4cf717064634f677558a7ec2c34d 100644 (file)
@@ -780,7 +780,7 @@ static MODCMD_FUNC(cmd_view) {
                 struct hs_toplevel *tlfh = slfh->toplevel;
                 //check if the user is already a manager of the tlfh
                 struct hs_manager *cmanager;
-                for(cmanager = tlfh->managers; cmanager; cmanager = cmanager->next) {
+                for(cmanager = tlfh->managers; cmanager; cmanager = cmanager->unext) {
                     if(cmanager->user == huser) break;
                 }
                 if(cmanager) continue;
@@ -1244,29 +1244,29 @@ static void hostserv_conf_read(void) {
     hostserv_conf.modes = (str ? str : NULL);
     
     str = database_get_data(conf_node, "toplevel_access", RECDB_QSTRING);
-    unsigned int toplevel_access = atoi(str);
+    unsigned int toplevel_access = (str ? atoi(str) : 0);
     hostserv_conf.toplevel_access = (toplevel_access ? toplevel_access : 600);
     
     str = database_get_data(conf_node, "fallback_other_assignment", RECDB_QSTRING);
-    hostserv_conf.fallback_other_assignment = (atoi(str) ? 1 : 0);
+    hostserv_conf.fallback_other_assignment = (str && atoi(str) ? 1 : 0);
     
     str = database_get_data(conf_node, "manager_can_del_toplevel", RECDB_QSTRING);
-    hostserv_conf.manager_can_del_toplevel = (atoi(str) ? 1 : 0);
+    hostserv_conf.manager_can_del_toplevel = (str && atoi(str) ? 1 : 0);
     
     str = database_get_data(conf_node, "manager_can_del_secondlevel", RECDB_QSTRING);
-    hostserv_conf.manager_can_del_secondlevel = (atoi(str) ? 1 : 0);
+    hostserv_conf.manager_can_del_secondlevel = (str && atoi(str) ? 1 : 0);
     
     str = database_get_data(conf_node, "manager_can_rename_toplevel", RECDB_QSTRING);
-    hostserv_conf.manager_can_rename_toplevel = (atoi(str) ? 1 : 0);
+    hostserv_conf.manager_can_rename_toplevel = (str && atoi(str) ? 1 : 0);
     
     str = database_get_data(conf_node, "manager_can_rename_secondlevel", RECDB_QSTRING);
-    hostserv_conf.manager_can_rename_secondlevel = (atoi(str) ? 1 : 0);
+    hostserv_conf.manager_can_rename_secondlevel = (str && atoi(str) ? 1 : 0);
     
     str = database_get_data(conf_node, "manager_toplevel_can_oset", RECDB_QSTRING);
-    hostserv_conf.manager_toplevel_can_oset = (atoi(str) ? 1 : 0);
+    hostserv_conf.manager_toplevel_can_oset = (str && atoi(str) ? 1 : 0);
     
     str = database_get_data(conf_node, "manager_secondlevel_can_oset", RECDB_QSTRING);
-    hostserv_conf.manager_secondlevel_can_oset = (atoi(str) ? 1 : 0);
+    hostserv_conf.manager_secondlevel_can_oset = (str && atoi(str) ? 1 : 0);
 }
 
 static int hostserv_saxdb_read_secondlevel(const char *name, void *data, UNUSED_ARG(void *extra));