mirror of
https://github.com/alsa-project/alsa-utils
synced 2024-12-22 23:06:30 +01:00
alsactl: terminate readlink result string
readlink does not guarantee that its result string is nul-terminated. Instead, increase the buffer by one byte to make sure that we can add '\0' at the end. Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
parent
46b6082756
commit
13c8269414
1 changed files with 2 additions and 2 deletions
|
@ -108,11 +108,11 @@ static char *sysfs_attr_get_value(const char *devpath, const char *attr_name)
|
|||
|
||||
if (S_ISLNK(statbuf.st_mode)) {
|
||||
/* links return the last element of the target path */
|
||||
char link_target[PATH_SIZE];
|
||||
char link_target[PATH_SIZE + 1];
|
||||
int len;
|
||||
const char *pos;
|
||||
|
||||
len = readlink(path_full, link_target, sizeof(link_target));
|
||||
len = readlink(path_full, link_target, sizeof(link_target) - 1);
|
||||
if (len > 0) {
|
||||
link_target[len] = '\0';
|
||||
pos = strrchr(link_target, '/');
|
||||
|
|
Loading…
Reference in a new issue