mirror of
https://github.com/isc-projects/bind9.git
synced 2026-04-27 17:17:22 -04:00
Address overrun in remove_old_tsversions
If too many versions of log / dnstap files to be saved where requests
the memory after to_keep could be overwritten. Force the number of
versions to be saved to a save level. Additionally the memmove length
was incorrect.
(cherry picked from commit 6ca78bc57d)
This commit is contained in:
parent
79179c6382
commit
67f85d648f
1 changed files with 6 additions and 4 deletions
|
|
@ -1153,10 +1153,13 @@ remove_old_tsversions(isc_logfile_t *file, int versions) {
|
|||
}
|
||||
|
||||
if (versions > 0) {
|
||||
if (versions > ISC_LOG_MAX_VERSIONS) {
|
||||
versions = ISC_LOG_MAX_VERSIONS;
|
||||
}
|
||||
/*
|
||||
* First we fill 'to_keep' structure using insertion sort
|
||||
*/
|
||||
memset(to_keep, 0, versions * sizeof(long long));
|
||||
memset(to_keep, 0, sizeof(to_keep));
|
||||
while (isc_dir_read(&dir) == ISC_R_SUCCESS) {
|
||||
if (dir.entry.length > bnamelen &&
|
||||
strncmp(dir.entry.name, bname, bnamelen) == 0 &&
|
||||
|
|
@ -1173,9 +1176,8 @@ remove_old_tsversions(isc_logfile_t *file, int versions) {
|
|||
if (i < versions) {
|
||||
memmove(&to_keep[i + 1],
|
||||
&to_keep[i],
|
||||
sizeof(long long) *
|
||||
versions -
|
||||
i - 1);
|
||||
sizeof(to_keep[0]) *
|
||||
(versions - i - 1));
|
||||
to_keep[i] = version;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue