authzone: fix memory leak in xfer_set_masters() error path (#1480)

Added memory deallocation for the `file` and `host` fields of the
`auth_master` node in the event of a URL/allocation error, and
unlinked the partially created node from the masters list by
resetting the link that pointed to it.

Signed-off-by: Petr Vaganov <petrvaganoff@gmail.com>
This commit is contained in:
Petr Vaganov
2026-07-24 12:24:49 +02:00
committed by GitHub
parent e597711824
commit e6d00725c2
+14 -1
View File
@@ -7596,35 +7596,48 @@ xfer_set_masters(struct auth_master** list, struct config_auth* c,
{
struct auth_master* m;
struct config_strlist* p;
struct auth_master** tail;
/* list points to the first, or next pointer for the new element */
while(*list) {
list = &( (*list)->next );
}
if(with_http)
for(p = c->urls; p; p = p->next) {
tail = list;
m = auth_master_new(&list);
if(!m) return 0;
m->http = 1;
if(!parse_url(p->str, &m->host, &m->file, &m->port, &m->ssl))
if(!parse_url(p->str, &m->host, &m->file, &m->port, &m->ssl)) {
free(m->host);
free(m->file);
free(m);
*tail = NULL;
return 0;
}
}
for(p = c->masters; p; p = p->next) {
tail = list;
m = auth_master_new(&list);
if(!m) return 0;
m->ixfr = 1; /* this flag is not configurable */
m->host = strdup(p->str);
if(!m->host) {
log_err("malloc failure");
free(m);
*tail = NULL;
return 0;
}
}
for(p = c->allow_notify; p; p = p->next) {
tail = list;
m = auth_master_new(&list);
if(!m) return 0;
m->allow_notify = 1;
m->host = strdup(p->str);
if(!m->host) {
log_err("malloc failure");
free(m);
*tail = NULL;
return 0;
}
}