Skip to content

Commit 88c2700

Browse files
jlebonrh-atomic-bot
authored andcommitted
daemon/deploy: Fix free() of override replace pkgs
We were using `g_strfreev()` to free the string array, but the strings themselves were owned by the `modifiers` GVariantDict. Fix this and make the comments about it more explicit. On my computer (and at least Dusty's), this was only actually tripping up libc when passing more than just one package on the CLI. Closes: #1707 Closes: #1709 Approved by: cgwalters
1 parent a1014ae commit 88c2700

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

src/daemon/rpmostreed-transaction-types.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -588,13 +588,13 @@ typedef struct {
588588
GVariantDict *modifiers;
589589
char *refspec; /* NULL for non-rebases */
590590
const char *revision; /* NULL for upgrade; owned by @options */
591-
char **install_pkgs; /* single malloc block pointing into GVariant, not strv; same for other *_pkgs */
591+
char **install_pkgs; /* strv but strings owned by modifiers */
592592
GUnixFDList *install_local_pkgs;
593-
char **uninstall_pkgs;
594-
char **override_replace_pkgs;
593+
char **uninstall_pkgs; /* strv but strings owned by modifiers */
594+
char **override_replace_pkgs; /* strv but strings owned by modifiers */
595595
GUnixFDList *override_replace_local_pkgs;
596-
char **override_remove_pkgs;
597-
char **override_reset_pkgs;
596+
char **override_remove_pkgs; /* strv but strings owned by modifiers */
597+
char **override_reset_pkgs; /* strv but strings owned by modifiers */
598598
} DeployTransaction;
599599

600600
typedef RpmostreedTransactionClass DeployTransactionClass;
@@ -619,7 +619,7 @@ deploy_transaction_finalize (GObject *object)
619619
g_free (self->install_pkgs);
620620
g_clear_pointer (&self->install_local_pkgs, g_object_unref);
621621
g_free (self->uninstall_pkgs);
622-
g_strfreev (self->override_replace_pkgs);
622+
g_free (self->override_replace_pkgs);
623623
g_clear_pointer (&self->override_replace_local_pkgs, g_object_unref);
624624
g_free (self->override_remove_pkgs);
625625
g_free (self->override_reset_pkgs);

tests/vmcheck/test-override-replace-2.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,13 @@ set -euo pipefail
2424

2525
set -x
2626

27+
# check that we error out right now if not providing an RPM
28+
if vm_rpmostree override replace foo bar baz |& tee out.txt; then
29+
assert_not_reached "Able to replace RPMs from repos?"
30+
fi
31+
assert_file_has_content out.txt "Non-local replacement overrides not implemented yet"
32+
echo "ok error on non-local replacements"
33+
2734
YUMREPO=/var/tmp/vmcheck/yumrepo/packages/x86_64
2835

2936
vm_assert_status_jq \

0 commit comments

Comments
 (0)