Skip to content
Merged
Show file tree
Hide file tree
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
8 changes: 8 additions & 0 deletions tools/tplg_parser/object.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,14 @@ int tplg_create_object(struct tplg_context *ctx,
return -EINVAL;
}

/* a zero-size array never advances the cursor below: bail out
* instead of looping forever on a malformed topology
*/
if (array->size == 0) {
fprintf(stderr, "error: load %s zero-size array\n", name);
return -EINVAL;
}
Comment on lines +68 to +71

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

%s is name (the object/widget type being loaded), matching the other error messages in this same function (e.g. "error: load %s array size mismatch"). Kept it consistent with the existing logging style here.


for (i = 0; i < ipc->num_groups; i++) {
const struct sof_topology_token *tokens = ipc->grp[i].tokens;
int num_tokens = ipc->grp[i].num_tokens;
Expand Down
10 changes: 10 additions & 0 deletions tools/tplg_parser/process.c
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,11 @@ static int process_append_data3(void *_process_ipc,

/* Size is process IPC plus private data minus ABI header */
bytes_ctl = (struct snd_soc_tplg_bytes_control *)ctl;
if (bytes_ctl->priv.size < sizeof(struct sof_abi_hdr)) {
fprintf(stderr, "error: process priv data too small: %u\n",
bytes_ctl->priv.size);
return -EINVAL;
}
Comment on lines +154 to +158

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

priv.size is __le32 (see struct snd_soc_tplg_private in sound/asoc.h), i.e. a 32-bit value, so %u is correct here — it's not a size_t.

size = bytes_ctl->priv.size - sizeof(struct sof_abi_hdr);
ipc_size = sizeof(struct sof_ipc_comp_process) + UUID_SIZE +
process_ipc->size + size;
Expand Down Expand Up @@ -184,6 +189,11 @@ static int process_append_data4(void *_process_ipc,

/* Size is process IPC plus private data minus ABI header */
bytes_ctl = (struct snd_soc_tplg_bytes_control *)ctl;
if (bytes_ctl->priv.size < sizeof(struct sof_abi_hdr)) {
fprintf(stderr, "error: process priv data too small: %u\n",
bytes_ctl->priv.size);
return -EINVAL;
}
Comment on lines +192 to +196

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Same — priv.size is __le32 (32-bit), so %u matches; no %zu needed.

size = bytes_ctl->priv.size - sizeof(struct sof_abi_hdr);

/* validate if everything will fit */
Expand Down
Loading