resolve conflicts

This commit is contained in:
z3APA3A 2020-11-02 18:59:13 +03:00
parent ce043e482a
commit d2366775a5
2 changed files with 138 additions and 23 deletions

View File

@ -125,7 +125,7 @@ int start_proxy_thread(struct child * chp){
#endif #endif
while(conf.threadinit)usleep(SLEEPTIME); while(conf.threadinit)usleep(SLEEPTIME);
if(haveerror) { if(haveerror) {
fprintf(stderr, "Service not started on line: %d\n", linenum); fprintf(stderr, "Service not started on line: %d%s\n", linenum, haveerror == 2? ": insufficient memory":"");
return(40); return(40);
} }
return 0; return 0;

View File

@ -280,8 +280,20 @@ int MODULEMAINFUNC (int argc, char** argv){
srv->service = defparam.service = childdef.service; srv->service = defparam.service = childdef.service;
#ifndef STDMAIN #ifndef STDMAIN
<<<<<<< HEAD
copyacl(conf.acl, srv); copyacl(conf.acl, srv);
srv->authfuncs = copyauth(conf.authfuncs); srv->authfuncs = copyauth(conf.authfuncs);
=======
if(conf.acl){
srv.acl = copyacl(conf.acl);
if(!srv.acl) haveerror = 2;
}
if(conf.authfuncs){
srv.authfuncs = copyauth(conf.authfuncs);
if(!srv.authfuncs) haveerror = 2;
}
>>>>>>> b81089f... More correct handling of insufficient memory
if(!conf.services){ if(!conf.services){
conf.services = srv; conf.services = srv;
} }
@ -973,7 +985,14 @@ struct auth * copyauth (struct auth * authfuncs){
struct auth * newauth = NULL; struct auth * newauth = NULL;
newauth = authfuncs = itcopy(authfuncs, sizeof(struct auth)); newauth = authfuncs = itcopy(authfuncs, sizeof(struct auth));
for( ; authfuncs; authfuncs = authfuncs->next = itcopy(authfuncs->next, sizeof(struct auth))); for( ; authfuncs->next; authfuncs = authfuncs->next){
authfuncs->next = itcopy(authfuncs->next, sizeof(struct auth));
if(!authfuncs->next)break;
}
if(authfuncs){
freeauth(newauth);
return NULL;
}
return newauth; return newauth;
} }
@ -987,29 +1006,107 @@ void copyacl (struct ace *ac, struct srvparam *srv){
int preacl = 1; int preacl = 1;
struct ace *acc; struct ace *acc;
ac = itcopy(ac, sizeof(struct ace)); for( ; ac; ac = ac->next){
for( ; ac; ac = ac->next = itcopy(ac->next, sizeof(struct ace))){ if(ac->src){
ac->src = itcopy(ac->src, sizeof(struct iplist)); ac->src = itcopy(ac->src, sizeof(struct iplist));
for(ipl = ac->src; ipl; ipl = ipl->next = itcopy(ipl->next, sizeof(struct iplist))); if(!ac->src) goto ERRORSRC;
for(ipl = ac->src; ipl->next; ipl = ipl->next){
ipl->next = itcopy(ipl->next, sizeof(struct iplist));
if(!ipl->next) goto ERRORSRC;
}
}
if(ac->dst){
ac->dst = itcopy(ac->dst, sizeof(struct iplist)); ac->dst = itcopy(ac->dst, sizeof(struct iplist));
for(ipl = ac->dst; ipl; ipl = ipl->next = itcopy(ipl->next, sizeof(struct iplist))); if(!ac->dst) goto ERRORDST;
for(ipl = ac->dst; ipl->next; ipl = ipl->next){
ipl->next = itcopy(ipl->next, sizeof(struct iplist));
if(!ipl->next) goto ERRORDST;
}
}
if(ac->ports){
ac->ports = itcopy(ac->ports, sizeof(struct portlist)); ac->ports = itcopy(ac->ports, sizeof(struct portlist));
for(pl = ac->ports; pl; pl = pl->next = itcopy(pl->next, sizeof(struct portlist))); if(!ac->ports) goto ERRORPORTS;
for(pl = ac->ports; pl->next; pl = pl->next){
pl->next = itcopy(pl->next, sizeof(struct portlist));
if(!pl->next) goto ERRORPORTS;
}
}
if(ac->periods){
ac->periods = itcopy(ac->periods, sizeof(struct period)); ac->periods = itcopy(ac->periods, sizeof(struct period));
for(pel = ac->periods; pel; pel = pel->next = itcopy(pel->next, sizeof(struct period))); if(!ac->periods) goto ERRORPERIODS;
for(pel = ac->periods; pel->next; pel = pel->next){
pel->next = itcopy(pel->next, sizeof(struct period));
if(!pel->next) goto ERRORPERIODS;
}
}
if(ac->users){
ac->users = itcopy(ac->users, sizeof(struct userlist)); ac->users = itcopy(ac->users, sizeof(struct userlist));
for(ul = ac->users; ul; ul = ul->next = itcopy(ul->next, sizeof(struct userlist))){ if(!ac->users) goto ERRORUSERS;
if(ul->user) ul->user = (char*)mystrdup((char *)ul->user); for(ul = ac->users; ul; ul = ul->next){
if(ul->user) {
ul->user = (unsigned char*)mystrdup((char *)ul->user);
if(!ul->user) {
ul->next = NULL;
goto ERRORUSERS;
} }
}
if(ul->next){
ul->next = itcopy(ul->next, sizeof(struct userlist));
if(!ul->next) goto ERRORUSERS;
}
}
}
if(ac->dstnames){
ac->dstnames = itcopy(ac->dstnames, sizeof(struct hostname)); ac->dstnames = itcopy(ac->dstnames, sizeof(struct hostname));
for(hst = ac->dstnames; hst; hst = hst->next = itcopy(hst->next, sizeof(struct hostname))){ if(!ac->dstnames) goto ERRORDSTNAMES;
if(hst->name) hst->name = (char*)mystrdup((char *)hst->name); for(hst = ac->dstnames; hst; hst = hst->next){
if(hst->name) {
hst->name = (unsigned char*)mystrdup((char *)hst->name);
if(!hst->name) {
hst->next = NULL;
goto ERRORDSTNAMES;
} }
}
if(hst->next){
hst->next = itcopy(hst->next, sizeof(struct hostname));
if(!hst->next) goto ERRORDSTNAMES;
}
}
}
if(ac->chains){
ac->chains = itcopy(ac->chains, sizeof(struct chain)); ac->chains = itcopy(ac->chains, sizeof(struct chain));
for(ch = ac->chains; ch; ch = ch->next = itcopy(ch->next, sizeof(struct chain))){ if(!ac->chains) goto ERRORCHAINS;
if(ch->extuser)ch->extuser = (char*)mystrdup((char *)ch->extuser); for(ch = ac->chains; ch; ch = ch->next){
if(ch->extpass)ch->extpass = (char*)mystrdup((char *)ch->extpass); if(ch->extuser){
if(ch->exthost)ch->exthost = (char*)mystrdup((char *)ch->exthost); ch->extuser = (unsigned char*)mystrdup((char *)ch->extuser);
if(!ch->extuser){
ch->extpass = NULL;
ch->exthost = NULL;
ch->next = NULL;
goto ERRORCHAINS;
}
}
if(ch->extpass){
ch->extpass = (unsigned char*)mystrdup((char *)ch->extpass);
if(!ch->extpass){
ch->exthost = NULL;
ch->next = NULL;
goto ERRORCHAINS;
}
}
if(ch->exthost){
ch->exthost = (unsigned char*)mystrdup((char *)ch->exthost);
if(!ch->exthost){
ch->next = NULL;
goto ERRORCHAINS;
}
}
if(ch->next){
ch->next = itcopy(ch->next, sizeof(struct chain));
if(!ch->next) goto ERRORCHAINS;
}
}
} }
if(preacl){ if(preacl){
if(ac->dst || ac->ports || ac->users || ac->dstnames || ac->chains|| ac->action>1){ if(ac->dst || ac->ports || ac->users || ac->dstnames || ac->chains|| ac->action>1){
@ -1026,6 +1123,24 @@ void copyacl (struct ace *ac, struct srvparam *srv){
} }
} }
if(!ac) return ret;
ERRORSRC:
ac->dst = NULL;
ERRORDST:
ac->ports = NULL;
ERRORPORTS:
ac->periods = NULL;
ERRORPERIODS:
ac->users = NULL;
ERRORUSERS:
ac->dstnames = NULL;
ERRORDSTNAMES:
ac->chains = NULL;
ERRORCHAINS:
ac->next = NULL;
freeacl(ret);
return NULL;
} }