Skip to content

Commit aff9552

Browse files
fix: tighten partition boundary failure checks
1 parent 4f73f74 commit aff9552

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

functions.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,13 @@ function syslog_partition_create($table, $time = null) {
349349
* and the source for the date string passed to TO_DAYS.
350350
*/
351351
$boundary_epoch = ((int)($time / 86400) + 1) * 86400;
352+
353+
if ($boundary_epoch <= 0 || $boundary_epoch <= $time) {
354+
cacti_log("SYSLOG ERROR: Boundary epoch computation overflow for '$table' (time=$time); rotation aborted", false, 'SYSLOG');
355+
356+
return false;
357+
}
358+
352359
$cformat = 'd' . gmdate('Ymd', $time);
353360
$boundary_date = gmdate('Y-m-d', $boundary_epoch);
354361

@@ -478,7 +485,7 @@ function syslog_partition_remove($table) {
478485
/* $table passed syslog_partition_table_allowed() at function entry; $part_name is regex-validated above. */
479486
$result = syslog_db_execute("ALTER TABLE `$syslogdb_default`.`$table` DROP PARTITION `$part_name`");
480487

481-
if ($result == 0) {
488+
if ($result === false) {
482489
cacti_log("SYSLOG ERROR: Failed to drop partition '$part_name' from '$table'; aborting further drops", false, 'SYSLOG');
483490
break;
484491
}

0 commit comments

Comments
 (0)