Skip to content

Commit

Permalink
teckpack: codecs: Use scnprintf() for robustness
Browse files Browse the repository at this point in the history
Reasoning explained here torvalds/linux@0623682

Also fixes this warning:
../techpack/audio/asoc/codecs/wcd-clsh.c:73:9: warning: ‘snprintf’ argument 4 overlaps destination object ‘buf’ [-Wrestrict]
   73 |   cnt = snprintf(buf, buflen - cnt - 1, "%s%s%s", buf,
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   74 |           buf[0] == '\0' ? "[" : "|",
      |           ~~~~~~~~~~~~~~~~~~~~~~~~~~~
   75 |           states[i]);
      |

Signed-off-by: Yaroslav Furman <yaro330@gmail.com>
Signed-off-by: Adam W. Willis <return.of.octobot@gmail.com>
Signed-off-by: CloudedQuartz <ravenklawasd@gmail.com>
  • Loading branch information
YaroST12 authored and CloudedQuartz committed Nov 27, 2021
1 parent c3f6bdd commit 6022396
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion techpack/audio/asoc/codecs/wcd-clsh.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ static const char *state_to_str(u8 state, char *buf, size_t buflen)
for (i = 0; i < ARRAY_SIZE(states); i++) {
if (!(state & (1 << i)))
continue;
cnt = snprintf(buf, buflen - cnt - 1, "%s%s%s", buf,
cnt = scnprintf(buf, buflen - cnt - 1, "%s%s%s", buf,
buf[0] == '\0' ? "[" : "|",
states[i]);
}
Expand Down
2 changes: 1 addition & 1 deletion techpack/audio/asoc/codecs/wcd9xxx-common-v2.c
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ static const char *state_to_str(u8 state, char *buf, size_t buflen)
for (i = 0; i < ARRAY_SIZE(states); i++) {
if (!(state & (1 << i)))
continue;
cnt = snprintf(buf, buflen - cnt - 1, "%s%s%s", buf,
cnt = scnprintf(buf, buflen - cnt - 1, "%s%s%s", buf,
buf[0] == '\0' ? "[" : "|",
states[i]);
}
Expand Down

0 comments on commit 6022396

Please sign in to comment.