Repository navigation
Conversation
FnCallFormat() hands each format piece straight to snprintf() or
BufferAppendF() with exactly one argument. The modifier denylist
("hLqjzt") lets through '*', which takes a width or precision from the
argument list, and '$', which selects a positional argument, so
format("%*d", 7) prints whatever is in the next vararg slot and
format("%2$s", "a") or format("%*s", "a") dereference a slot that was
never passed as a char *. 'l' on %s/%S makes printf read the char *
argument as a wchar_t *, 4 bytes per character past the end of the
string.
The format argument is expanded before the function runs, so a
variable interpolated into it (file contents, module output, data
container values) can carry such a specifier.
Changelog: Title
Signed-off-by: Dhanraj E <dhanraj@labs.digiscrypt.com>
GetServerLiteral() zeroed and formatted CF_BUFSIZE bytes into the sendbuffer it was handed, but BusyWithNewProtocol() allocates that buffer as CF_BUFSIZE - CF_INBAND_OFFSET bytes (the most a single transaction can carry). Any VAR request admitted by the literals ACL therefore wrote 8 bytes past the end of the handler's stack buffer. Pass the buffer size into GetServerLiteral(), as DoExec2() already does, and bound the writes to it. Both callers pass sizeof(sendbuffer). Changelog: Title Signed-off-by: Dhanraj E <dhanraj@labs.digiscrypt.com>
The "xattr" branch of filestat() reads each extended attribute value
into an uninitialized stack buffer and then uses it as a C string:
char data[CF_BUFSIZE];
int datasize = lgetxattr(path, current, data, sizeof(data));
...
if (!StringIsPrintable(data))
...
BufferPrintf(printattr, "%s=%s", current, data);
lgetxattr() returns raw bytes and never adds a terminating NUL. An
unprivileged user can set user.* attributes on files they own, so when
a policy run as root calls filestat() on such a file, a printable value
of exactly 4096 bytes makes StringIsPrintable() read past the end of
data. Shorter values are followed by whatever stale stack bytes come
before the next NUL, which either makes a valid attribute get skipped
as non-printable or copies stack contents into the returned string.
Read at most sizeof(data) - 1 bytes and terminate the value at
datasize. CopyFileExtendedAttributesDisk() in files_copy.c, the other
lgetxattr() caller, handles values by length and is not affected.
Changelog: Title
Signed-off-by: Dhanraj E <dhanraj@labs.digiscrypt.com>
Ticket: CFE-3898 Changelog: None Signed-off-by: Nick Anderson <nick@cmdln.org>
Added the reactor tests to jenkins, to be able to run them in jenkins. This means we can test cf-reactor on all the different platforms. Signed-off-by: Victor Moene <victor.moene@northern.tech>
Made the logs prettier and added a log file where the xtrace is printed Signed-off-by: Victor Moene <victor.moene@northern.tech>
The guest environment cannot contain "-". On hosts containing "-", the promise fails. The host name is now canonofied. Signed-off-by: Victor Moene <victor.moene@northern.tech>
X509_get_subject_name() now returns a const name. Build a new X509_NAME and set it as both subject and issuer instead. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Lars Erik Wik <lars.erik.wik@northern.tech>
Tests that print Pass message but have logs errors will fail with `FAIL (Error printed)` message. Tests which are expected to log errors should use `.error.cf` or `.error.pass.cf` suffix. see: `tests/acceptance/README` Ticket: CFE-3041 Signed-off-by: Ihor Aleksandrychiev <ihor.aleksandrychiev@northern.tech>
These tests read files created by their own init bundle, but pre-evaluation calls the read functions before the files exist, logging "Could not examine file" errors which now fail regular tests. Ticket: CFE-3041 Signed-off-by: Ihor Aleksandrychiev <ihor.aleksandrychiev@northern.tech>
Errors printed by the command were reported on lines starting with "error:", so testall mistook them for errors of the test itself. Ticket: CFE-3041 Signed-off-by: Ihor Aleksandrychiev <ihor.aleksandrychiev@northern.tech>
These tests read files and directories created by their own policy, but pre-evaluation calls the functions before they exist, logging errors which now fail regular tests. Ticket: CFE-3041 Signed-off-by: Ihor Aleksandrychiev <ihor.aleksandrychiev@northern.tech>
The agent loads def.json from the directory of the input policy file, so tests in 00_basics/ tried to read this directory as their augments file and logged "Could not open JSON file" errors. Ticket: CFE-3041 Signed-off-by: Ihor Aleksandrychiev <ihor.aleksandrychiev@northern.tech>
The test used the 'immediate' body from plucked.sub.cf before it was loaded during pre-evaluation, so the promise is now skipped until the test framework is loaded. Ticket: CFE-3041 Signed-off-by: Ihor Aleksandrychiev <ihor.aleksandrychiev@northern.tech>
The test referred to a promise module which never existed and did not run its init and cleanup bundles. Ticket: CFE-3041 Signed-off-by: Ihor Aleksandrychiev <ihor.aleksandrychiev@northern.tech>
The check bundle counted lines in files which do not exist until the test bundle has run, but the agent evaluates the functions of all promises before any bundle runs. Ticket: CFE-3041 Signed-off-by: Ihor Aleksandrychiev <ihor.aleksandrychiev@northern.tech>
wrong-bundle-type.cf printed the sub-agent output in its DEBUG report, so the sub-agent errors were mistaken for errors of the test, and ifelse.cf used invalid class expressions as false conditions. Ticket: CFE-3041 Signed-off-by: Ihor Aleksandrychiev <ihor.aleksandrychiev@northern.tech>
These tests intentionally exercise error paths, the reason is documented in the header of each test. Ticket: CFE-3041 Signed-off-by: Ihor Aleksandrychiev <ihor.aleksandrychiev@northern.tech>
Signed-off-by: Ihor Aleksandrychiev <ihor.aleksandrychiev@northern.tech>
Ticket: CFE-3041 Signed-off-by: Nick Anderson <nick@cmdln.org>
Ticket: CFE-3041 Signed-off-by: Nick Anderson <nick@cmdln.org>
Ticket: CFE-3041
The errorpass branch only checked for logged errors and the Pass message, so a test marked test_soft_fail or test_skip_unsupported was reported as FAIL (e.g. process_select_fncalls.error.pass.cf on Windows, which soft fails due to ENT-10217 and logs no errors there). Errorpass tests now go through the regular outcome handling and only differ in requiring at least one logged error on Pass.
Ticket: CFE-3041 Signed-off-by: Nick Anderson <nick@cmdln.org>
Signed-off-by: Dhanraj E <dhanraj@labs.digiscrypt.com>
Signed-off-by: Lars Erik Wik <lars.erik.wik@northern.tech>
Signed-off-by: Lars Erik Wik <lars.erik.wik@northern.tech>
…ptions() public Signed-off-by: Lars Erik Wik <lars.erik.wik@northern.tech>
Signed-off-by: Lars Erik Wik <lars.erik.wik@northern.tech>
Signed-off-by: Lars Erik Wik <lars.erik.wik@northern.tech>
cf-check: Fix segfault on missing state directory
…assed-args Made format() reject specifiers that read unpassed printf arguments
Signed-off-by: Lars Erik Wik <lars.erik.wik@northern.tech>
Co-authored-by: Lars Erik Wik <53906608+larsewi@users.noreply.github.com>
Signed-off-by: Lars Erik Wik <lars.erik.wik@northern.tech>
…ror-messages cf-reactor: fix watchers on windows
ENT-14717: Made the backport action a reusable workflow
…changelog-master docs: update changelog for master
cf-agent reconstructs the absolute target of a relative symbolic link by appending the readlink() result onto the link's directory name in a CF_BUFSIZE stack buffer. KillGhostLink() in files_links.c did this with an unbounded strcat(linkpath, linkbuf), and LinkCopy() in verify_files_utils.c with strncat(vbuff, linkbuf, CF_BUFSIZE - 1), whose third argument is the maximum number of bytes to take from the source, not the space left in the destination. readlink() returns up to CF_BUFSIZE - 1 bytes, so a symlink whose relative target is near CF_BUFSIZE, left by an unprivileged user in a directory that a root files promise walks (depth_search, perms, link copy), overflows the stack of the agent. KillGhostLink() runs on every symlink met during a recursive descent, before the dead-link stat(). Bound both appends with strlcat(..., sizeof(buf)), the same way ExpandLinks() in files_links.c already does. KillGhostLink() bails out with an "Internal limit reached" message and LinkCopy() fails the promise when the target does not fit, rather than truncating it into a link pointing somewhere else. Normal links are unchanged. The regression test is skipped when symlink() rejects the long target with ENAMETOOLONG, as macOS does. Changelog: Title Signed-off-by: Dhanraj E <dhanraj@labs.digiscrypt.com>
…th-overflow fix stack overflow building absolute path from relative symlink target
Ticket: ENT-14717 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Lars Erik Wik <lars.erik.wik@northern.tech>
Signed-off-by: Ihor Aleksandrychiev <ihor.aleksandrychiev@northern.tech>
Bumped .CFVERSION number to 3.30.0
Ticket: CFE-3478 Signed-off-by: Victor Moene <victor.moene@northern.tech>
ENT-14717: Now removes the cherry-pick? label after successful backports
ENT-14927: Fixed cf-serverd crash when policy reload races with a new connection
…talls DiffPkgOperations() compared the versions of two recorded installations of the same package without checking that both were set, which PkgVersionIsGreater() asserts. The diff report now keeps the record the way the manifest report does: a versioned record over an unversioned one, otherwise the higher version, otherwise the first one recorded. Ticket: none Changelog: Title Signed-off-by: Daniel JB Clark <djbclark@gmail.com> Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
CFE-3478: Added isvalidip: function for validating IP addresses
Changelog: None
…sioned-install-assert Fixed simulate diff mode aborting on repeated unversioned package installs
Branch protection patterns like "*" do not match "/", so the old backport-<PR>-<branch> name was blocked in repos protecting all branches. Changelog: None Signed-off-by: Ihor Aleksandrychiev <ihor.aleksandrychiev@northern.tech>
Changed backport branch name to backport/<PR>-<branch>
This was referenced Nov 12, 2026
…check Checked RAND_bytes() result when creating bootstrap_id.dat
Signed-off-by: Ole Herman Schumacher Elgesem <ole@northern.tech>
Reject null scalar values and keep loading valid entries. Changelog: Title Ticket: none Signed-off-by: Daniel JB Clark <djbclark@gmail.com>
djbclark
force-pushed
the
fix/cmdb-null-value-crash-r4
branch
from
November 14, 2026 17:27
ca1d1c6 to
9e309c6
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Rejected null scalar variable values in
host_specific.jsonwith a named error, instead of crashing during context loading. Valid neighboring entries continue loading; list and nested-container behavior is unchanged.Fixes #21
Refreshed from #63; that branch and its historical evidence are preserved. Current head:
ca1d1c69e2b4240e0d1cc3dba9a44f8072ecb85f. Base: upstream270e6c36f4d0dcf73ded78d28ae9d7cfd9013564. Two commits: the fix/regression and JSON fixture formatting. The fork master is older; the focused three-file diff excludes unrelated upstream history.Human verification is pending: plain-language logic review on the fork issue. No upstream submission until that review, exact-text/diff review and explicit approval.
Exact-head validation
Ubuntu 24.04 aarch64,
--enable-debug, root, no network; rerun after formatting:cmdb.cto the upstream base, retain the tests, rebuild: new regression fails (0/1), with an assert abort.cf-promisesandcf-agent: eight SIGABRT exits (-6) without the fix; eight exits of 0 with the fix, named rejection and surviving neighbor. Mixed/all-null lists, nested data and the tendcf projector fixture are six additional case/binary controls; all exit 0 both ways. Total 28 before/after probe runs.b68070a2105ca33f04844f74ec3a2e23a912dc6b. Apply-check only, not runtime verification of that refactor.Initial CI stopped at JSON fixture formatting. CFEngine's formatter changed whitespace only (parsed JSON equality verified). Current CI run is still running; formatting, lint, shellcheck, Linux unit and ASan checks have passed so far.
Independent reviews
Both reviewed independently at high effort and confirmed the final head after the formatting-only delta and fresh runtime evidence:
Reviews checked ownership cleanup, both loaders, compatibility, regression discrimination and upstream wording. Neither reviewer reran the tests. Optional notes retained: stricter diagnostic matching and extra metadata/tag coverage could improve the test; no blocking defect was identified. All commissioned reviews have reported.
AI-assisted. No upstream submission yet. Upstream will receive a short self-contained summary with optional links to this PR and the fork issue; the exact diff/text still requires operator review.