Skip to content

fix: Repair three fatal defects in the cacti, wmdata and rrd datasources - #244

Merged
TheWitness merged 1 commit into
build/test-harnessfrom
fix/datasource-fatal-errors
Aug 30, 2026
Merged

fix: Repair three fatal defects in the cacti, wmdata and rrd datasources#244
TheWitness merged 1 commit into
build/test-harnessfrom
fix/datasource-fatal-errors

Conversation

@somethingwithproof

Copy link
Copy Markdown
Member

Three defects that stop a datasource dead, all reachable from a normal poller
run. Each is covered by a test that fails without the change.

  • string_or_null() is called in the cacti and wmdata datasources and defined
    nowhere in the plugin or in Cacti, so every cacti: target read ended in
    Error: Call to undefined function. The surrounding datasources already use
    an inline null check; these now match.
  • the wmdata: target regex had no closing delimiter. preg_match() returned
    false, $datafile stayed unset, and file_exists() raised a TypeError under
    that file's strict_types. The same method also opened $targetstring
    rather than $datafile and never closed the handle.
  • the rrd_options guard used '/["\'\\]/', which PCRE reads as an unterminated
    character class, so preg_match() returned false and the check never
    rejected anything. It is now one strpbrk() predicate shared by both call
    sites. Options were passed through cacti_escapeshellarg() either way, so
    nothing was injectable through the dead guard.

Verification: 130 passed on 8.1, 8.3 and 8.4.

Second of seven; needs #1.

string_or_null() is called in the cacti and wmdata sources but is defined
nowhere in the plugin or in Cacti core, so every cacti: target read ended in
a fatal Error; the surrounding files already use an inline null check, so
these now match.  wmdata carried a target regex with no closing delimiter,
which left $datafile unset and made file_exists() a TypeError under that
file's strict_types, opened $targetstring instead of $datafile, and never
closed the handle.  The rrd_options guard used '/["\'\\]/', which PCRE reads
as an unterminated character class, so preg_match() returned false and the
check never rejected anything; it is now one strpbrk() predicate shared by
both call sites.  Options were escaped with cacti_escapeshellarg() either
way, so no injection was reachable through the dead guard.

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
@TheWitness
TheWitness merged commit 5dd8c82 into build/test-harness Aug 30, 2026
@TheWitness
TheWitness deleted the fix/datasource-fatal-errors branch August 30, 2026 20:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants