resolve conflicts

This commit is contained in:
z3APA3A 2020-11-03 11:16:04 +03:00
parent 82d827180d
commit 98ff3464f7
2 changed files with 25 additions and 19 deletions

View File

@ -244,7 +244,6 @@ int checkpreACL(struct clientparam * param);
extern int havelog; extern int havelog;
unsigned long udpresolve(int af, char * name, char * value, unsigned *retttl, struct clientparam* param, int makeauth); unsigned long udpresolve(int af, char * name, char * value, unsigned *retttl, struct clientparam* param, int makeauth);
void copyacl (struct ace *ac, struct srvparam *srv);
struct auth * copyauth (struct auth *); struct auth * copyauth (struct auth *);
void * itfree(void *data, void * retval); void * itfree(void *data, void * retval);
void freeacl(struct ace *ac); void freeacl(struct ace *ac);

View File

@ -9,6 +9,7 @@
#include "proxy.h" #include "proxy.h"
void srvpostfree(struct srvparam * srv); void srvpostfree(struct srvparam * srv);
static int copyacl (struct ace *ac, struct srvparam *srv);
#define param ((struct clientparam *) p) #define param ((struct clientparam *) p)
#ifdef _WIN32 #ifdef _WIN32
@ -280,20 +281,14 @@ 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);
srv->authfuncs = copyauth(conf.authfuncs);
=======
if(conf.acl){ if(conf.acl){
srv.acl = copyacl(conf.acl); if(copyacl(conf.acl, srv)) haveerror = 2;
if(!srv.acl) haveerror = 2;
} }
if(conf.authfuncs){ if(conf.authfuncs){
srv.authfuncs = copyauth(conf.authfuncs); srv->authfuncs = copyauth(conf.authfuncs);
if(!srv.authfuncs) haveerror = 2; if(!srv->authfuncs) haveerror = 2;
} }
>>>>>>> b81089f... More correct handling of insufficient memory
if(!conf.services){ if(!conf.services){
conf.services = srv; conf.services = srv;
} }
@ -984,11 +979,13 @@ static void * itcopy (void * from, size_t size){
struct auth * copyauth (struct auth * authfuncs){ struct auth * copyauth (struct auth * authfuncs){
struct auth * newauth = NULL; struct auth * newauth = NULL;
newauth = authfuncs = itcopy(authfuncs, sizeof(struct auth)); newauth = itcopy(authfuncs, sizeof(struct auth));
for( ; authfuncs->next; authfuncs = authfuncs->next){ for( authfuncs=newauth; authfuncs; authfuncs = authfuncs->next){
if(authfuncs->next){
authfuncs->next = itcopy(authfuncs->next, sizeof(struct auth)); authfuncs->next = itcopy(authfuncs->next, sizeof(struct auth));
if(!authfuncs->next)break; if(!authfuncs->next)break;
} }
}
if(authfuncs){ if(authfuncs){
freeauth(newauth); freeauth(newauth);
return NULL; return NULL;
@ -996,7 +993,7 @@ struct auth * copyauth (struct auth * authfuncs){
return newauth; return newauth;
} }
void copyacl (struct ace *ac, struct srvparam *srv){ static int copyacl (struct ace *ac, struct srvparam *srv){
struct iplist *ipl; struct iplist *ipl;
struct portlist *pl; struct portlist *pl;
struct userlist *ul; struct userlist *ul;
@ -1004,8 +1001,11 @@ void copyacl (struct ace *ac, struct srvparam *srv){
struct period *pel; struct period *pel;
struct hostname *hst; struct hostname *hst;
int preacl = 1; int preacl = 1;
struct ace *acc;
if(ac) {
ac = itcopy(ac, sizeof(struct ace));
if(!ac) return 21;
}
for(; ac; ac = ac->next){ for(; ac; ac = ac->next){
if(ac->src){ if(ac->src){
ac->src = itcopy(ac->src, sizeof(struct iplist)); ac->src = itcopy(ac->src, sizeof(struct iplist));
@ -1108,8 +1108,14 @@ void copyacl (struct ace *ac, struct srvparam *srv){
} }
} }
} }
if(ac->next){
ac->next = itcopy(ac->next, sizeof(struct ace));
if(!ac->next) goto ERRORNEXT;
}
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){
struct ace *acc;
preacl = 0; preacl = 0;
for(acc = srv->preacl; acc; acc=acc->next)if(acc->next == ac) { for(acc = srv->preacl; acc; acc=acc->next)if(acc->next == ac) {
acc->next = NULL; acc->next = NULL;
@ -1123,7 +1129,7 @@ void copyacl (struct ace *ac, struct srvparam *srv){
} }
} }
if(!ac) return ret; if(!ac) return 0;
ERRORSRC: ERRORSRC:
ac->dst = NULL; ac->dst = NULL;
ERRORDST: ERRORDST:
@ -1138,8 +1144,9 @@ ERRORDSTNAMES:
ac->chains = NULL; ac->chains = NULL;
ERRORCHAINS: ERRORCHAINS:
ac->next = NULL; ac->next = NULL;
ERRORNEXT:
freeacl(ret); freeacl(ret);
return NULL; return 21;
} }