Skip to content

Commit 680e126

Browse files
rfvirgilbroonie
authored andcommitted
firmware: cs_dsp: Use strnlen() on name fields in V1 wmfw files
Use strnlen() instead of strlen() on the algorithm and coefficient name string arrays in V1 wmfw files. In V1 wmfw files the name is a NUL-terminated string in a fixed-size array. cs_dsp should protect against overrunning the array if the NUL terminator is missing. Signed-off-by: Richard Fitzgerald <[email protected]> Fixes: f6bc909 ("firmware: cs_dsp: add driver to support firmware loading on Cirrus Logic DSPs") Link: https://patch.msgid.link/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 82bb8db commit 680e126

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/firmware/cirrus/cs_dsp.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1182,7 +1182,7 @@ static int cs_dsp_coeff_parse_alg(struct cs_dsp *dsp,
11821182

11831183
blk->id = le32_to_cpu(raw->id);
11841184
blk->name = raw->name;
1185-
blk->name_len = strlen(raw->name);
1185+
blk->name_len = strnlen(raw->name, ARRAY_SIZE(raw->name));
11861186
blk->ncoeff = le32_to_cpu(raw->ncoeff);
11871187

11881188
pos = sizeof(*raw);
@@ -1258,7 +1258,7 @@ static int cs_dsp_coeff_parse_coeff(struct cs_dsp *dsp,
12581258
return -EOVERFLOW;
12591259

12601260
blk->name = raw->name;
1261-
blk->name_len = strlen(raw->name);
1261+
blk->name_len = strnlen(raw->name, ARRAY_SIZE(raw->name));
12621262
blk->ctl_type = le16_to_cpu(raw->ctl_type);
12631263
blk->flags = le16_to_cpu(raw->flags);
12641264
blk->len = le32_to_cpu(raw->len);

0 commit comments

Comments
 (0)