Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stable-v2.12] rimage: fix resource leak #9743

Merged
merged 2 commits into from
Dec 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions tools/rimage/src/manifest.c
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,7 @@ static int man_module_create_reloc(struct image *image, struct manifest_module *

if (!n_mod || n_mod * sizeof(*sof_mod) != section.header.data.size) {
fprintf(stderr, "error: Invalid module manifests in '.module' section.\n");
elf_section_free(&section);
return -ENOEXEC;
}

Expand All @@ -512,6 +513,8 @@ static int man_module_create_reloc(struct image *image, struct manifest_module *
unsigned int j;

strncpy(name, (char *)sof_mod->module.name, SOF_MAN_MOD_NAME_LEN);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/strncpy/strlcpy ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would be a further update if needed, I think we are good to go today with @abonislawski fix.

/* Ensure null termination */
name[SOF_MAN_MOD_NAME_LEN] = '\0';

for (j = 0; j < image->adsp->modules->mod_man_count; j++) {
if (!strncmp(name, (char *)image->adsp->modules->mod_man[j].name,
Expand All @@ -530,6 +533,7 @@ static int man_module_create_reloc(struct image *image, struct manifest_module *

if (j == image->adsp->modules->mod_man_count) {
fprintf(stderr, "error: cannot find %s in manifest.\n", name);
elf_section_free(&section);
return -ENOEXEC;
}
}
Expand Down
Loading