Fix acl copy / auth copy out-of-memory error

This commit is contained in:
z3APA3A 2020-11-03 11:16:04 +03:00
parent c1c5875356
commit dbbbe59ef2

View File

@ -1038,11 +1038,13 @@ static void * itcopy (void * from, size_t size){
struct auth * copyauth (struct auth * authfuncs){
struct auth * newauth = NULL;
newauth = authfuncs = itcopy(authfuncs, sizeof(struct auth));
for( ; authfuncs->next; authfuncs = authfuncs->next){
newauth = itcopy(authfuncs, sizeof(struct auth));
for( authfuncs=newauth; authfuncs; authfuncs = authfuncs->next){
if(authfuncs->next){
authfuncs->next = itcopy(authfuncs->next, sizeof(struct auth));
if(!authfuncs->next)break;
}
}
if(authfuncs){
freeauth(newauth);
return NULL;
@ -1059,8 +1061,8 @@ struct ace * copyacl (struct ace *ac){
struct period *pel;
struct hostname *hst;
ret = ac = itcopy(ac, sizeof(struct ace));
for( ; ac->next; ac = ac->next){
ret = itcopy(ac, sizeof(struct ace));
for( ac = ret; ac; ac = ac->next){
if(ac->src){
ac->src = itcopy(ac->src, sizeof(struct iplist));
if(!ac->src) goto ERRORSRC;
@ -1162,6 +1164,10 @@ struct ace * copyacl (struct ace *ac){
}
}
}
if(ac->next){
ac->next = itcopy(ac->next, sizeof(struct ace));
if(!ac->next) break;
}
}
if(!ac) return ret;
ERRORSRC: