- Backport a few fix patches from upstream, mostly for fixing crashes in multi-thread programs: 0044-configure-do-not-detect-incorrect-cross-compiler.patch 0045-ucm-Set-uc_mgr-ctl-to-NULL-after-closing-it.patch 0046-snd_pcm_direct_parse_open_conf-use-thread-safe-getgr.patch 0047-Add-snd_lib_error_set_local-to-install-a-thread-loca.patch 0048-snd_device_name_hint-do-not-change-the-global-error-.patch 0049-snd_device_name_hint-do-not-use-global-snd_config.patch 0050-conf-Fix-a-memory-access-violation-resulting-from-im.patch OBS-URL: https://build.opensuse.org/request/show/150679 OBS-URL: https://build.opensuse.org/package/show/multimedia:libs/alsa?expand=0&rev=123
42 lines
1.3 KiB
Diff
42 lines
1.3 KiB
Diff
From 2cfc8b9b44a8e493c41b3d63d5a00b306a18a5ed Mon Sep 17 00:00:00 2001
|
|
From: Jerome Forissier <jerome@taodyne.com>
|
|
Date: Wed, 30 Jan 2013 16:22:17 +0100
|
|
Subject: [PATCH 46/50] snd_pcm_direct_parse_open_conf(): use thread-safe
|
|
getgrnam_r()
|
|
|
|
Fixes a thread safety issue with snd_pcm_open().
|
|
|
|
Signed-off-by: Jerome Forissier <jerome@taodyne.com>
|
|
Signed-off-by: Takashi Iwai <tiwai@suse.de>
|
|
---
|
|
src/pcm/pcm_direct.c | 15 +++++++++++----
|
|
1 file changed, 11 insertions(+), 4 deletions(-)
|
|
|
|
--- a/src/pcm/pcm_direct.c
|
|
+++ b/src/pcm/pcm_direct.c
|
|
@@ -1629,13 +1629,20 @@ int snd_pcm_direct_parse_open_conf(snd_c
|
|
continue;
|
|
}
|
|
if (isdigit(*group) == 0) {
|
|
- struct group *grp = getgrnam(group);
|
|
- if (grp == NULL) {
|
|
+ long clen = sysconf(_SC_GETGR_R_SIZE_MAX);
|
|
+ size_t len = (clen == -1) ? 1024 : (size_t)clen;
|
|
+ struct group grp, *pgrp;
|
|
+ char *buffer = (char *)malloc(len);
|
|
+ if (buffer == NULL)
|
|
+ return -ENOMEM;
|
|
+ int st = getgrnam_r(group, &grp, buffer, len, &pgrp);
|
|
+ if (st != 0) {
|
|
SNDERR("The field ipc_gid must be a valid group (create group %s)", group);
|
|
- free(group);
|
|
+ free(buffer);
|
|
return -EINVAL;
|
|
}
|
|
- rec->ipc_gid = grp->gr_gid;
|
|
+ rec->ipc_gid = pgrp->gr_gid;
|
|
+ free(buffer);
|
|
} else {
|
|
rec->ipc_gid = strtol(group, &endp, 10);
|
|
}
|