Repository navigation
Various fixes - #6722
Merged
Merged
Various fixes#6722
Conversation
This should be the case anyway right now and makes it easier to ensure the code using it is correct.
It was accidentally parsed into the product union member but because it has the same layout as the vendor one, this didn't turn into a bug in practice, but it probably is UB.
Copy and paste error which results in the default and explicit usage of --clear-env to be inverted. Fixes: f760f1b ("run: Add --clear-env option for clearing the outside environment")
It also adds autofd cleanup and simplifies the control flow a bit.
This doesn't seem to happen in practice, but the API says it's possible, so we better abort than run into weird states.
The code checked the wrong flags. struct_props is the array of child properties, so struct_props->flags is the flags of the first child property. What we need to chech is the flags of the current property, and if it contains FLATPAK_JSON_PROP_FLAGS_STRICT.
We specifically have to avoid holding the lock while calling flatpak_installation_get_dir_maybe_no_repo, so we just double check if it is unset.
_ostree_object_name_equal() derived both refs from parameter a, so any two objects in the same hash bucket were considered equal. This caused g_hash_table_add() to evict previously inserted objects on hash collision, shrinking the reachable set below its true size and potentially pruning objects that are still in use.
Collaborator
Author
|
Not really sure who to ping for this. It's small changes all over the place. /cc @smcv @owtaylor @AdrianVovk @alexlarsson |
swick
force-pushed
the
wip/various-fixes-novuln
branch
2 times, most recently
from
June 30, 2026 22:01
99a8a60 to
ce1b392
Compare
owtaylor
reviewed
Jul 3, 2026
owtaylor
left a comment
Contributor
There was a problem hiding this comment.
That's quite a pile of fixes!
Generally everything looks solid to me. Just a few places noted here where the fix isn't quite right (and a few more where a change seems unnecessary but harmless.)
If max_len is 0, either data1_len or data2_len is 0, which means we would add -1 to either data1 or data2, making them point one byte before the object which is UB. This commit just changes match_bytes_at_end and match_bytes_at_start to use index based comparisons which makes the code easier and less likely to invoke UB.
glib-mkenums fails to generate proper nicks and strips away th non- and no-. Fix those cases manually. Also fix the header guard while at it. Technically this is an API break, but the API does exactly the opposite of what it promises, so if anyone depended on this, we probably would have received a bug report. Let's take the risk and just change it.
If we created an instance and we failed to get the PID of the instance, we would still succeed. If one later calls flatpak_instance_is_running or uses the result of flatpak_instance_get_pid with kill, it's possible to terminate the entire process group (kill 0). Let's just error out as early as possible to avoid those weird half-initialized cases. That unfortunately means we have to adjust a bunch of callers as well, but fortunately, this only affects internal API.
If a negated true conditional (e.g. `!true`) is evaludated, it should
always be considered false. However, the code would not do that
(continue to the next conditional), but instead falls through to the
evaluator which grants the permission, because
evaluator (condition) == !negated
... and the evaluator evaluates unknown conditions as false.
We would abort when the first conditional was already in the merged set of conditionals.
If validation failed, we fall back to wayland-0, but we passed the unvalidated name to flatpak_run_create_wayland_security_context.
The check tests sandbox_flags but the error message formatted arg_flags, showing unrelated spawn flags instead of the actual unsupported sandbox flags.
Both pid file writes silently ignored errors by passing NULL for the GError. Log a warning so the failure is at least observable.
A symlink loop on the host filesystem would cause infinite recursion and a stack overflow. Limit to 40 levels, matching the kernel's ELOOP limit and the existing check in _exports_path_expose.
st_size is a 64-bit off_t but was truncated to gsize which is 32-bit on 32-bit platforms. A file larger than G_MAXSIZE - 1 would cause size + 1 to overflow to 0, leading to a zero-size allocation followed by an oversized read.
The setter used "summary-history-length" but the getter used "sumary-history-length", so the configured value was never read and the default was always used.
branch, commit, and app_path are read from the instance info key file and could be NULL if the keys are missing. This would lead to NULL dereferences in g_file_new_for_path, g_variant_new_string, or printf %s. Fail early with an error instead.
g_subprocess_new can return NULL if the fusermount binary is not found. The NULL was passed directly to g_subprocess_wait_check, causing a NULL dereference.
Add the same early remote name validation (reject empty or containing '/') that other D-Bus handlers already perform, for consistency. The validation is not required for correctness or security but rejects obviously invalid input at the entry point.
The warning for a failed g_file_monitor_file call used error->message but the error was stored in local_error. If polkit succeeded, error is NULL, causing a NULL dereference.
g_file_replace can return NULL on failure (e.g. disk full). The result was passed to g_converter_output_stream_new before the NULL check. Move the check before use.
g_file_equal returns TRUE when paths are equal, so the != 0 check was triggering a reload when the path was unchanged and keeping the stale cache when the path changed to a different file.
Handle NULL from g_key_file_get_string when a desktop file has no Icon key, and from flatpak_dir_get_origin when deploy metadata is missing or corrupted.
When bundle metadata validation fails after commit, the ref cleanup via ostree_repo_set_ref_immediate could set error, then flatpak_fail_error would try to set it again. Pass NULL for the cleanup call since it's best-effort.
swick
force-pushed
the
wip/various-fixes-novuln
branch
from
July 3, 2026 12:21
ce1b392 to
80ec289
Compare
1 of 2 tasks
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.
All of those issues fell out of an LLM. I analyzed each issue, discarded a bunch, and either worked on, or at least verified the fixes.