SHA256
1
0
forked from pool/alsa-utils
alsa-utils/0006-alsactl-terminate-readlink-result-string.patch
Takashi Iwai fa525f71d0 Accepting request 316472 from home:tiwai:branches:multimedia:libs
- Backport upstream fixes for aplay signal handling and alsactl
  possible buffer overflow of readlink():
  0004-aplay-Fix-type-for-signal-flag.patch
  0005-aplay-Fix-uninterruptible-aplay.patch
  0006-alsactl-terminate-readlink-result-string.patch

OBS-URL: https://build.opensuse.org/request/show/316472
OBS-URL: https://build.opensuse.org/package/show/multimedia:libs/alsa-utils?expand=0&rev=118
2015-07-13 15:41:56 +00:00

36 lines
1.2 KiB
Diff

From 13c826941445a66ece203a09e6739c979ac5900c Mon Sep 17 00:00:00 2001
From: Tobias Stoeckmann <tobias@stoeckmann.org>
Date: Sat, 11 Jul 2015 13:23:57 +0200
Subject: [PATCH] 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>
---
alsactl/init_sysfs.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/alsactl/init_sysfs.c b/alsactl/init_sysfs.c
index 0cbada2e169b..5c789b61b0e5 100644
--- a/alsactl/init_sysfs.c
+++ b/alsactl/init_sysfs.c
@@ -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, '/');
--
2.4.5