memerror in uid-get. reinsert save config yang spec (removed for wrong reasons previously causing memleaks)

This commit is contained in:
Olof hagsand 2019-12-01 16:48:45 +01:00
parent 69b27f3280
commit c4954f5c43
9 changed files with 83 additions and 15 deletions

View file

@ -109,6 +109,8 @@ backend_terminate(clicon_handle h)
xml_free(x);
if ((yspec = clicon_dbspec_yang(h)) != NULL)
yspec_free(yspec);
if ((yspec = clicon_config_yang(h)) != NULL)
yspec_free(yspec);
if ((nsctx = clicon_nsctx_global_get(h)) != NULL)
cvec_free(nsctx);
if ((x = clicon_nacm_ext(h)) != NULL)
@ -507,7 +509,7 @@ main(int argc,
clicon_log_init(__PROGRAM__, debug?LOG_DEBUG:LOG_INFO, logdst);
clicon_debug_init(debug, NULL);
/* Create configure yang-spec */
/* Create configure yang-spec (note different from dbspec holding application specs) */
if ((yspecfg = yspec_new()) == NULL)
goto done;
@ -517,6 +519,9 @@ main(int argc,
usage(h, argv[0]);
return -1;
}
if (clicon_config_yang_set(h, yspecfg) < 0)
goto done;
/* External NACM file? */
nacm_mode = clicon_option_str(h, "CLICON_NACM_MODE");
if (nacm_mode && strcmp(nacm_mode, "external") == 0)

View file

@ -270,10 +270,12 @@ backend_accept_client(int fd,
#error "Need getsockopt O_PEERCRED or getpeereid for unix socket peer cred"
#endif
if (name != NULL){
if ((ce->ce_username = strdup(name)) == NULL){
if ((ce->ce_username = name) == NULL){
clicon_err(OE_UNIX, errno, "strdup");
name = NULL;
goto done;
}
name = NULL;
}
break;
case AF_INET:
@ -291,5 +293,7 @@ backend_accept_client(int fd,
goto done;
retval = 0;
done:
if (name)
free(name);
return retval;
}