Takashi Iwai
40ecd60af0
- Backport upstream fixes: new OXFW hwdep definition, chmap print overflow fix, improvement of UCM parser, GoogleNyan UCM config, removal of gethostbyname() usages: 0061-hwdep-add-OXFW-driver-support.patch 0062-pcm-fix-buffer-overflow-in-snd_pcm_chmap_print.patch 0063-control-enable-octal-and-hexadecimal-parse.patch 0064-autotools-fix-ucm-partial-build.patch 0065-conf-ucm-GoogleNyan-Add-configuration.patch 0066-ucm-add-binary-configure-file-parse.patch 0067-Remove-unused-hostname-resolution-in-shm-plugins-and.patch - Suppress timestamps in the generated documents for make the package comparison easier OBS-URL: https://build.opensuse.org/request/show/283172 OBS-URL: https://build.opensuse.org/package/show/multimedia:libs/alsa?expand=0&rev=176
324 lines
8.1 KiB
Diff
324 lines
8.1 KiB
Diff
From dbb7eca6559e970bd015eaa95a9e0525660fa09e Mon Sep 17 00:00:00 2001
|
|
From: Takashi Iwai <tiwai@suse.de>
|
|
Date: Wed, 28 Jan 2015 16:21:14 +0100
|
|
Subject: [PATCH] Remove unused hostname resolution in shm plugins and aserver
|
|
|
|
PCM and control shm plugins and aserver have some codes to resolve the
|
|
host address and check whether it's a local host although the given
|
|
address is never used. In addition, the code contains gethostbyname()
|
|
that is known to be obsoleted. So, let's get rid of all these unused
|
|
codes.
|
|
|
|
The host configuration item is still accepted (but just ignored) for
|
|
keeping the compatibility.
|
|
|
|
Signed-off-by: Takashi Iwai <tiwai@suse.de>
|
|
---
|
|
aserver/aserver.c | 24 +-------------------
|
|
include/aserver.h | 1
|
|
src/control/control_shm.c | 49 +----------------------------------------
|
|
src/pcm/pcm_shm.c | 53 +--------------------------------------------
|
|
src/socket.c | 54 ----------------------------------------------
|
|
5 files changed, 6 insertions(+), 175 deletions(-)
|
|
|
|
--- a/aserver/aserver.c
|
|
+++ b/aserver/aserver.c
|
|
@@ -1013,11 +1013,10 @@ int main(int argc, char **argv)
|
|
snd_config_t *conf;
|
|
snd_config_iterator_t i, next;
|
|
const char *sockname = NULL;
|
|
- const char *host = NULL;
|
|
long port = -1;
|
|
int err;
|
|
char *srvname;
|
|
- struct hostent *h;
|
|
+
|
|
command = argv[0];
|
|
while ((c = getopt_long(argc, argv, "h", long_options, 0)) != -1) {
|
|
switch (c) {
|
|
@@ -1055,14 +1054,8 @@ int main(int argc, char **argv)
|
|
continue;
|
|
if (strcmp(id, "comment") == 0)
|
|
continue;
|
|
- if (strcmp(id, "host") == 0) {
|
|
- err = snd_config_get_string(n, &host);
|
|
- if (err < 0) {
|
|
- ERROR("Invalid type for %s", id);
|
|
- return 1;
|
|
- }
|
|
+ if (strcmp(id, "host") == 0)
|
|
continue;
|
|
- }
|
|
if (strcmp(id, "socket") == 0) {
|
|
err = snd_config_get_string(n, &sockname);
|
|
if (err < 0) {
|
|
@@ -1082,19 +1075,6 @@ int main(int argc, char **argv)
|
|
ERROR("Unknown field %s", id);
|
|
return 1;
|
|
}
|
|
- if (!host) {
|
|
- ERROR("host is not defined");
|
|
- return 1;
|
|
- }
|
|
- h = gethostbyname(host);
|
|
- if (!h) {
|
|
- ERROR("Cannot resolve %s", host);
|
|
- return 1;
|
|
- }
|
|
- if (!snd_is_local(h)) {
|
|
- ERROR("%s is not the local host", host);
|
|
- return 1;
|
|
- }
|
|
if (!sockname && port < 0) {
|
|
ERROR("either socket or port need to be defined");
|
|
return 1;
|
|
--- a/include/aserver.h
|
|
+++ b/include/aserver.h
|
|
@@ -23,7 +23,6 @@
|
|
#include "../src/control/control_local.h"
|
|
|
|
int snd_receive_fd(int sock, void *data, size_t len, int *fd);
|
|
-int snd_is_local(struct hostent *hent);
|
|
|
|
typedef enum _snd_dev_type {
|
|
SND_DEV_TYPE_PCM,
|
|
--- a/src/control/control_shm.c
|
|
+++ b/src/control/control_shm.c
|
|
@@ -441,29 +441,6 @@ static int make_local_socket(const char
|
|
return sock;
|
|
}
|
|
|
|
-#if 0
|
|
-static int make_inet_socket(const char *host, int port)
|
|
-{
|
|
- struct sockaddr_in addr;
|
|
- int sock;
|
|
- struct hostent *h = gethostbyname(host);
|
|
- if (!h)
|
|
- return -ENOENT;
|
|
-
|
|
- sock = socket(PF_INET, SOCK_STREAM, 0);
|
|
- if (sock < 0)
|
|
- return -errno;
|
|
-
|
|
- addr.sin_family = AF_INET;
|
|
- addr.sin_port = htons(port);
|
|
- memcpy(&addr.sin_addr, h->h_addr_list[0], sizeof(struct in_addr));
|
|
-
|
|
- if (connect(sock, (struct sockaddr *) &addr, sizeof(addr)) < 0)
|
|
- return -errno;
|
|
- return sock;
|
|
-}
|
|
-#endif
|
|
-
|
|
int snd_ctl_shm_open(snd_ctl_t **handlep, const char *name, const char *sockname, const char *sname, int mode)
|
|
{
|
|
snd_ctl_t *ctl;
|
|
@@ -565,12 +542,10 @@ int _snd_ctl_shm_open(snd_ctl_t **handle
|
|
const char *server = NULL;
|
|
const char *ctl_name = NULL;
|
|
snd_config_t *sconfig;
|
|
- const char *host = NULL;
|
|
const char *sockname = NULL;
|
|
long port = -1;
|
|
int err;
|
|
- int local;
|
|
- struct hostent *h;
|
|
+
|
|
snd_config_for_each(i, next, conf) {
|
|
snd_config_t *n = snd_config_iterator_entry(i);
|
|
const char *id;
|
|
@@ -624,14 +599,8 @@ int _snd_ctl_shm_open(snd_ctl_t **handle
|
|
continue;
|
|
if (strcmp(id, "comment") == 0)
|
|
continue;
|
|
- if (strcmp(id, "host") == 0) {
|
|
- err = snd_config_get_string(n, &host);
|
|
- if (err < 0) {
|
|
- SNDERR("Invalid type for %s", id);
|
|
- goto _err;
|
|
- }
|
|
+ if (strcmp(id, "host") == 0)
|
|
continue;
|
|
- }
|
|
if (strcmp(id, "socket") == 0) {
|
|
err = snd_config_get_string(n, &sockname);
|
|
if (err < 0) {
|
|
@@ -653,24 +622,10 @@ int _snd_ctl_shm_open(snd_ctl_t **handle
|
|
goto _err;
|
|
}
|
|
|
|
- if (!host) {
|
|
- SNDERR("host is not defined");
|
|
- goto _err;
|
|
- }
|
|
if (!sockname) {
|
|
SNDERR("socket is not defined");
|
|
goto _err;
|
|
}
|
|
- h = gethostbyname(host);
|
|
- if (!h) {
|
|
- SNDERR("Cannot resolve %s", host);
|
|
- goto _err;
|
|
- }
|
|
- local = snd_is_local(h);
|
|
- if (!local) {
|
|
- SNDERR("%s is not the local host", host);
|
|
- goto _err;
|
|
- }
|
|
err = snd_ctl_shm_open(handlep, name, sockname, ctl_name, mode);
|
|
_err:
|
|
snd_config_delete(sconfig);
|
|
--- a/src/pcm/pcm_shm.c
|
|
+++ b/src/pcm/pcm_shm.c
|
|
@@ -654,33 +654,6 @@ static int make_local_socket(const char
|
|
return sock;
|
|
}
|
|
|
|
-#if 0
|
|
-static int make_inet_socket(const char *host, int port)
|
|
-{
|
|
- struct sockaddr_in addr;
|
|
- int sock;
|
|
- struct hostent *h = gethostbyname(host);
|
|
- if (!h)
|
|
- return -ENOENT;
|
|
-
|
|
- sock = socket(PF_INET, SOCK_STREAM, 0);
|
|
- if (sock < 0) {
|
|
- SYSERR("socket failed");
|
|
- return -errno;
|
|
- }
|
|
-
|
|
- addr.sin_family = AF_INET;
|
|
- addr.sin_port = htons(port);
|
|
- memcpy(&addr.sin_addr, h->h_addr_list[0], sizeof(struct in_addr));
|
|
-
|
|
- if (connect(sock, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
|
|
- SYSERR("connect failed");
|
|
- return -errno;
|
|
- }
|
|
- return sock;
|
|
-}
|
|
-#endif
|
|
-
|
|
/**
|
|
* \brief Creates a new shared memory PCM
|
|
* \param pcmp Returns created PCM handle
|
|
@@ -842,12 +815,10 @@ int _snd_pcm_shm_open(snd_pcm_t **pcmp,
|
|
const char *server = NULL;
|
|
const char *pcm_name = NULL;
|
|
snd_config_t *sconfig;
|
|
- const char *host = NULL;
|
|
const char *sockname = NULL;
|
|
long port = -1;
|
|
int err;
|
|
- int local;
|
|
- struct hostent *h;
|
|
+
|
|
snd_config_for_each(i, next, conf) {
|
|
snd_config_t *n = snd_config_iterator_entry(i);
|
|
const char *id;
|
|
@@ -898,14 +869,8 @@ int _snd_pcm_shm_open(snd_pcm_t **pcmp,
|
|
continue;
|
|
if (strcmp(id, "comment") == 0)
|
|
continue;
|
|
- if (strcmp(id, "host") == 0) {
|
|
- err = snd_config_get_string(n, &host);
|
|
- if (err < 0) {
|
|
- SNDERR("Invalid type for %s", id);
|
|
- goto _err;
|
|
- }
|
|
+ if (strcmp(id, "host") == 0)
|
|
continue;
|
|
- }
|
|
if (strcmp(id, "socket") == 0) {
|
|
err = snd_config_get_string(n, &sockname);
|
|
if (err < 0) {
|
|
@@ -928,24 +893,10 @@ int _snd_pcm_shm_open(snd_pcm_t **pcmp,
|
|
goto __error;
|
|
}
|
|
|
|
- if (!host) {
|
|
- SNDERR("host is not defined");
|
|
- goto _err;
|
|
- }
|
|
if (!sockname) {
|
|
SNDERR("socket is not defined");
|
|
goto _err;
|
|
}
|
|
- h = gethostbyname(host);
|
|
- if (!h) {
|
|
- SNDERR("Cannot resolve %s", host);
|
|
- goto _err;
|
|
- }
|
|
- local = snd_is_local(h);
|
|
- if (!local) {
|
|
- SNDERR("%s is not the local host", host);
|
|
- goto _err;
|
|
- }
|
|
err = snd_pcm_shm_open(pcmp, name, sockname, pcm_name, stream, mode);
|
|
__error:
|
|
snd_config_delete(sconfig);
|
|
--- a/src/socket.c
|
|
+++ b/src/socket.c
|
|
@@ -106,58 +106,4 @@ int snd_receive_fd(int sock, void *data,
|
|
*fd = *fds;
|
|
return ret;
|
|
}
|
|
-
|
|
-int snd_is_local(struct hostent *hent)
|
|
-{
|
|
- int s;
|
|
- int err;
|
|
- struct ifconf conf;
|
|
- size_t numreqs = 10;
|
|
- size_t i;
|
|
- struct in_addr *haddr = (struct in_addr*) hent->h_addr_list[0];
|
|
-
|
|
- s = socket(PF_INET, SOCK_STREAM, 0);
|
|
- if (s < 0) {
|
|
- SYSERR("socket failed");
|
|
- return -errno;
|
|
- }
|
|
-
|
|
- conf.ifc_len = numreqs * sizeof(struct ifreq);
|
|
- conf.ifc_buf = malloc((unsigned int) conf.ifc_len);
|
|
- if (! conf.ifc_buf) {
|
|
- close(s);
|
|
- return -ENOMEM;
|
|
- }
|
|
- while (1) {
|
|
- err = ioctl(s, SIOCGIFCONF, &conf);
|
|
- if (err < 0) {
|
|
- SYSERR("SIOCGIFCONF failed");
|
|
- close(s);
|
|
- return -errno;
|
|
- }
|
|
- if ((size_t)conf.ifc_len < numreqs * sizeof(struct ifreq))
|
|
- break;
|
|
- numreqs *= 2;
|
|
- conf.ifc_len = numreqs * sizeof(struct ifreq);
|
|
- conf.ifc_buf = realloc(conf.ifc_buf, (unsigned int) conf.ifc_len);
|
|
- if (! conf.ifc_buf) {
|
|
- close(s);
|
|
- return -ENOMEM;
|
|
- }
|
|
- }
|
|
- numreqs = conf.ifc_len / sizeof(struct ifreq);
|
|
- for (i = 0; i < numreqs; ++i) {
|
|
- struct ifreq *req = &conf.ifc_req[i];
|
|
- struct sockaddr_in *s_in = (struct sockaddr_in *)&req->ifr_addr;
|
|
- s_in->sin_family = AF_INET;
|
|
- err = ioctl(s, SIOCGIFADDR, req);
|
|
- if (err < 0)
|
|
- continue;
|
|
- if (haddr->s_addr == s_in->sin_addr.s_addr)
|
|
- break;
|
|
- }
|
|
- close(s);
|
|
- free(conf.ifc_buf);
|
|
- return i < numreqs;
|
|
-}
|
|
#endif
|