Skip to content

Harden modulemd_module_add_... functions against null-pointer dereferences - #641

Merged
ppisar merged 3 commits into
fedora-modularity:mainfrom
ppisar:add_transalation_obsoletes_check_null
Aug 11, 2026
Merged

Harden modulemd_module_add_... functions against null-pointer dereferences#641
ppisar merged 3 commits into
fedora-modularity:mainfrom
ppisar:add_transalation_obsoletes_check_null

Conversation

@ppisar

@ppisar ppisar commented Aug 10, 2026

Copy link
Copy Markdown
Collaborator

modulemd_module_add_obsoletes() and modulemd_module_add_translation() do not expect modules, translation, or obsletes objects with NULL module name. While it is not a problem in current use of these function, we cannot guarantee it in the future and we should add preconditions against the NULL names.

Found by Fedora 45 static analysis in August 2026 https://svashisht.fedorapeople.org/openscanhub/mass-scans/f45-03-Aug-2026/libmodulemd-2.15.3-3.fc45/scan-results.html.

ppisar and others added 3 commits August 10, 2026 16:39
…ences

When the function checks that a module name of the module and the
translations are equal, g_str_equal() functions is called. That
function does not handle NULL arguments.

While we do not pass modules or translations with NULL names to this
private function now, it's better to hardern the function against it.

This patch adds more preconditions to
modulemd_module_add_translation() in order to prevent passing NULL to
g_str_equal().

Again, automated tests are impossible becase Glib test framework fatalizes
the preconditions.
When the function checks that a module name of the module and the
obsoletes are equal, g_str_equal() functions is called. That
function does not handle NULL arguments.

While we do not pass modules or obsoletes with NULL names to this
private function now, it's better to harden the function against it.

This patch adds more preconditions to modulemd_module_add_obsoletes()
in order to prevent passing NULL to g_str_equal().

Again, automated tests are impossible becase Glib test framework fatalizes
the preconditions.
Signed-off-by: Libmodulemd CI <github-actions@github.com>
@sonarqubecloud

Copy link
Copy Markdown

@ppisar
ppisar merged commit d88ae43 into fedora-modularity:main Aug 11, 2026
21 of 22 checks passed
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