- Fix leak in chroot fix for auth-zone.

git-svn-id: file:///svn/unbound/trunk@4989 be551aaa-1e26-0410-a405-d3ace91eadb9
This commit is contained in:
Wouter Wijngaards 2018-11-28 12:37:52 +00:00
parent f95f98b12a
commit 3330d5296c
2 changed files with 11 additions and 1 deletions

View file

@ -1,3 +1,6 @@
28 November 2018: Wouter
- Fix leak in chroot fix for auth-zone.
27 November 2018: Wouter 27 November 2018: Wouter
- Fix DNS64 to not store intermediate results in cache, this avoids - Fix DNS64 to not store intermediate results in cache, this avoids
other threads from picking up the wrong data. The module restores other threads from picking up the wrong data. The module restores

View file

@ -1484,7 +1484,6 @@ az_parse_file(struct auth_zone* z, FILE* in, uint8_t* rr, size_t rrbuflen,
incfile++; incfile++;
/* adjust for chroot on include file */ /* adjust for chroot on include file */
incfile = fname_after_chroot(incfile, cfg, 1); incfile = fname_after_chroot(incfile, cfg, 1);
incfile = strdup(incfile);
if(!incfile) { if(!incfile) {
log_err("malloc failure"); log_err("malloc failure");
return 0; return 0;
@ -1564,11 +1563,13 @@ auth_zone_read_zonefile(struct auth_zone* z, struct config_file* cfg)
verbose(VERB_ALGO, "no zonefile %s for %s", verbose(VERB_ALGO, "no zonefile %s for %s",
zfilename, n?n:"error"); zfilename, n?n:"error");
free(n); free(n);
free(zfilename);
return 1; return 1;
} }
log_err("cannot open zonefile %s for %s: %s", log_err("cannot open zonefile %s for %s: %s",
zfilename, n?n:"error", strerror(errno)); zfilename, n?n:"error", strerror(errno));
free(n); free(n);
free(zfilename);
return 0; return 0;
} }
@ -1590,9 +1591,11 @@ auth_zone_read_zonefile(struct auth_zone* z, struct config_file* cfg)
log_err("error parsing zonefile %s for %s", log_err("error parsing zonefile %s for %s",
zfilename, n?n:"error"); zfilename, n?n:"error");
free(n); free(n);
free(zfilename);
fclose(in); fclose(in);
return 0; return 0;
} }
free(zfilename);
fclose(in); fclose(in);
return 1; return 1;
} }
@ -4829,6 +4832,7 @@ xfr_write_after_update(struct auth_xfer* xfr, struct module_env* env)
verbose(VERB_ALGO, "tmpfilename too long, cannot update " verbose(VERB_ALGO, "tmpfilename too long, cannot update "
" zonefile %s", zfilename); " zonefile %s", zfilename);
lock_rw_unlock(&z->lock); lock_rw_unlock(&z->lock);
free(zfilename);
return; return;
} }
snprintf(tmpfile, sizeof(tmpfile), "%s.tmp%u", zfilename, snprintf(tmpfile, sizeof(tmpfile), "%s.tmp%u", zfilename,
@ -4842,6 +4846,7 @@ xfr_write_after_update(struct auth_xfer* xfr, struct module_env* env)
} else if(!auth_zone_write_file(z, tmpfile)) { } else if(!auth_zone_write_file(z, tmpfile)) {
unlink(tmpfile); unlink(tmpfile);
lock_rw_unlock(&z->lock); lock_rw_unlock(&z->lock);
free(zfilename);
return; return;
} }
if(rename(tmpfile, zfilename) < 0) { if(rename(tmpfile, zfilename) < 0) {
@ -4849,9 +4854,11 @@ xfr_write_after_update(struct auth_xfer* xfr, struct module_env* env)
strerror(errno)); strerror(errno));
unlink(tmpfile); unlink(tmpfile);
lock_rw_unlock(&z->lock); lock_rw_unlock(&z->lock);
free(zfilename);
return; return;
} }
lock_rw_unlock(&z->lock); lock_rw_unlock(&z->lock);
free(zfilename);
} }
/** process chunk list and update zone in memory, /** process chunk list and update zone in memory,