--- libaitcfg/src/aitcfg.c 2014/03/03 09:41:09 1.12 +++ libaitcfg/src/aitcfg.c 2023/01/23 23:27:26 1.16 @@ -3,7 +3,7 @@ * by Michael Pounov * * $Author: misho $ -* $Id: aitcfg.c,v 1.12 2014/03/03 09:41:09 misho Exp $ +* $Id: aitcfg.c,v 1.16 2023/01/23 23:27:26 misho Exp $ * ************************************************************************** The ELWIX and AITNET software is distributed under the following @@ -12,7 +12,7 @@ terms: All of the documentation and software included in the ELWIX and AITNET Releases is copyrighted by ELWIX - Sofia/Bulgaria -Copyright 2004 - 2014 +Copyright 2004 - 2023 by Michael Pounov . All rights reserved. Redistribution and use in source and binary forms, with or without @@ -71,8 +71,8 @@ cfg_tree_cmp(struct tagCfg *a, struct tagCfg *b) assert(a && b); - ret = ((AIT_KEY(&a->cfg_sec) << 16) | AIT_KEY(&a->cfg_attr)) - - ((AIT_KEY(&b->cfg_sec) << 16) | AIT_KEY(&b->cfg_attr)); + ret = ((AIT_KEY(&a->cfg_sec) << 15) | AIT_KEY(&a->cfg_attr)) - + ((AIT_KEY(&b->cfg_sec) << 15) | AIT_KEY(&b->cfg_attr)); if (ret < 0) return -1; @@ -173,6 +173,8 @@ cfgLoadConfig(const char *cfgName, cfg_root_t * __rest cfg_SetErr(EINVAL, "Invalid parameter(s)"); return -1; } else { + memset(cfg, 0, sizeof(cfg_root_t)); + pthread_mutex_init(&cfg->rc_mtx, NULL); TAILQ_INIT(cfg); @@ -257,7 +259,7 @@ cfgCreateConfig(const char *csConfigName, cfg_root_t * return -1; } - ret = cfgWriteConfig(f, cfg, whitespace); + ret = cfgWriteConfigRaw(f, cfg, whitespace); fclose(f); return ret; @@ -321,6 +323,8 @@ cfgLoadPasswd(const char *pwdName, pwd_root_t * __rest cfg_SetErr(EINVAL, "Invalid parameter(s)"); return -1; } else { + memset(pwd, 0, sizeof(pwd_root_t)); + pthread_mutex_init(&pwd->pwd_mtx, NULL); SLIST_INIT(pwd);