diff options
author | Minecrell <minecrell@minecrell.net> | 2020-04-23 18:15:57 +0200 |
---|---|---|
committer | Minecrell <minecrell@minecrell.net> | 2020-04-23 18:16:43 +0200 |
commit | 3f469bfc2c2b891d13a5236baa9b5ef1028f2389 (patch) | |
tree | 28b264d81184df7023830b2badaf26cff066c0dc /utils | |
parent | 24ac96246da13b968c19fdee6da07a072031c9ba (diff) |
tinyalsa: use strncpy instead of memcpy to copy string constant
memcpy() is arguably wrong when copying these string constants.
The string constants will usually just be as long as necessary,
so we might copy some random memory behind it and eventually crash.
Use strncpy() instead to avoid copying characters after the null
terminator. For some reason the strings in snd_ctl_card_info use
unsigned chars, so we need a cast to char* to make it compile
unfortunately...
This fixes the following compile error on ppc64le:
In function 'mixer_plug_get_card_info',
inlined from 'mixer_plug_ioctl' at mixer_plugin.c:371:15:
mixer_plugin.c:333:5: error: 'memcpy' forming offset [9, 16] is out of the bounds [0, 8] [-Werror=array-bounds]
333 | memcpy(card_info->id, "card_id", sizeof(card_info->id));
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Not sure why that warning does not exist on other architectures.
Diffstat (limited to 'utils')
0 files changed, 0 insertions, 0 deletions