[xiph-commits] r9554 - icecast/branches/kh/icecast/src
karl at svn.xiph.org
karl at svn.xiph.org
Fri Jul 8 19:18:00 PDT 2005
Author: karl
Date: 2005-07-08 19:17:56 -0700 (Fri, 08 Jul 2005)
New Revision: 9554
Modified:
icecast/branches/kh/icecast/src/cfgfile.c
icecast/branches/kh/icecast/src/fserve.c
icecast/branches/kh/icecast/src/yp.c
Log:
fix NULL pointer bug in yp.c for max_listeners. Add checks in config read
to avoid incomplete mount/relay settings
Modified: icecast/branches/kh/icecast/src/cfgfile.c
===================================================================
--- icecast/branches/kh/icecast/src/cfgfile.c 2005-07-07 13:24:35 UTC (rev 9553)
+++ icecast/branches/kh/icecast/src/cfgfile.c 2005-07-09 02:17:56 UTC (rev 9554)
@@ -113,14 +113,56 @@
_set_defaults(configuration);
}
+
+static void config_clear_relay (relay_server *relay)
+{
+ xmlFree (relay->server);
+ xmlFree (relay->mount);
+ xmlFree (relay->localmount);
+ free (relay);
+}
+
+
+static void config_clear_mount (mount_proxy *mount)
+{
+ config_options_t *option;
+
+ xmlFree (mount->mountname);
+ xmlFree (mount->username);
+ xmlFree (mount->password);
+ xmlFree (mount->dumpfile);
+ xmlFree (mount->intro_filename);
+ xmlFree (mount->on_connect);
+ xmlFree (mount->on_disconnect);
+ xmlFree (mount->fallback_mount);
+ xmlFree (mount->stream_name);
+ xmlFree (mount->stream_description);
+ xmlFree (mount->stream_url);
+ xmlFree (mount->stream_genre);
+ xmlFree (mount->bitrate);
+ xmlFree (mount->type);
+ xmlFree (mount->cluster_password);
+
+ xmlFree (mount->auth_type);
+ option = mount->auth_options;
+ while (option)
+ {
+ config_options_t *nextopt = option->next;
+ xmlFree (option->name);
+ xmlFree (option->value);
+ free (option);
+ option = nextopt;
+ }
+ auth_release (mount->auth);
+ free (mount);
+}
+
+
void config_clear(ice_config_t *c)
{
ice_config_dir_t *dirnode, *nextdirnode;
- relay_server *relay, *nextrelay;
- mount_proxy *mount, *nextmount;
aliases *alias, *nextalias;
int i;
- config_options_t *option;
if (c->config_filename)
free(c->config_filename);
@@ -169,53 +211,20 @@
if (c->group) xmlFree(c->group);
thread_mutex_lock(&(_locks.relay_lock));
- relay = c->relay;
- while(relay) {
- nextrelay = relay->next;
- xmlFree(relay->server);
- xmlFree(relay->mount);
- xmlFree(relay->localmount);
- free(relay);
- relay = nextrelay;
+ while (c->relay)
+ {
+ relay_server *to_go = c->relay;
+ c->relay = to_go->next;
+ config_clear_relay (to_go);
}
thread_mutex_unlock(&(_locks.relay_lock));
- mount = c->mounts;
- while(mount) {
- nextmount = mount->next;
- xmlFree(mount->mountname);
- xmlFree(mount->username);
- xmlFree(mount->password);
- xmlFree(mount->dumpfile);
- xmlFree(mount->intro_filename);
- xmlFree(mount->on_connect);
- xmlFree(mount->on_disconnect);
- xmlFree(mount->fallback_mount);
- xmlFree(mount->stream_name);
- xmlFree(mount->stream_description);
- xmlFree(mount->stream_url);
- xmlFree(mount->stream_genre);
- xmlFree(mount->bitrate);
- xmlFree(mount->type);
- if (mount->cluster_password) {
- xmlFree(mount->cluster_password);
- }
-
- xmlFree(mount->auth_type);
- option = mount->auth_options;
- while(option) {
- config_options_t *nextopt = option->next;
- xmlFree(option->name);
- xmlFree(option->value);
- free(option);
- option = nextopt;
- }
- auth_release (mount->auth);
-
- free(mount);
- mount = nextmount;
+ while (c->mounts)
+ {
+ mount_proxy *to_go = c->mounts;
+ c->mounts = to_go->next;
+ config_clear_mount (to_go);
}
-
alias = c->aliases;
while(alias) {
nextalias = alias->next;
@@ -535,16 +544,6 @@
mount_proxy *current = configuration->mounts;
mount_proxy *last=NULL;
- while(current) {
- last = current;
- current = current->next;
- }
-
- if(last)
- last->next = mount;
- else
- configuration->mounts = mount;
-
/* default <mount> settings */
mount->max_listeners = -1;
mount->burst_size = -1;
@@ -672,6 +671,21 @@
doc, node->xmlChildrenNode, 1);
}
} while ((node = node->next));
+
+ if (mount->mountname == NULL)
+ {
+ config_clear_mount (mount);
+ return;
+ }
+ while(current) {
+ last = current;
+ current = current->next;
+ }
+
+ if(last)
+ last->next = mount;
+ else
+ configuration->mounts = mount;
}
@@ -680,23 +694,12 @@
{
char *tmp;
relay_server *relay = calloc(1, sizeof(relay_server));
- relay_server *current = configuration->relay;
- relay_server *last=NULL;
- while(current) {
- last = current;
- current = current->next;
- }
-
- if(last)
- last->next = relay;
- else
- configuration->relay = relay;
-
relay->next = NULL;
relay->mp3metadata = 1;
relay->enable = 1;
relay->on_demand = configuration->on_demand;
+ relay->port = 8000;
do {
if (node == NULL) break;
@@ -743,8 +746,20 @@
if (tmp) xmlFree(tmp);
}
} while ((node = node->next));
+
+ if (relay->server == NULL)
+ {
+ config_clear_relay (relay);
+ return;
+ }
+ if (relay->mount == NULL)
+ relay->mount = xmlStrdup ("/");
+
if (relay->localmount == NULL)
relay->localmount = xmlStrdup (relay->mount);
+
+ relay->next = configuration->relay;
+ configuration->relay = relay;
}
static void _parse_listen_socket(xmlDocPtr doc, xmlNodePtr node,
@@ -1039,6 +1054,8 @@
{
mount_proxy *mountinfo = config->mounts, *global = NULL;
+ if (mount == NULL)
+ return NULL;
while (mountinfo)
{
if (strcmp (mountinfo->mountname, "all") == 0)
Modified: icecast/branches/kh/icecast/src/fserve.c
===================================================================
--- icecast/branches/kh/icecast/src/fserve.c 2005-07-07 13:24:35 UTC (rev 9553)
+++ icecast/branches/kh/icecast/src/fserve.c 2005-07-09 02:17:56 UTC (rev 9554)
@@ -68,7 +68,7 @@
#endif
static fserve_t *active_list = NULL;
-volatile static fserve_t *pending_list = NULL;
+static volatile fserve_t *pending_list = NULL;
static mutex_t pending_lock;
static avl_tree *mimetypes = NULL;
@@ -235,7 +235,7 @@
static void *fserv_thread_function(void *arg)
{
fserve_t *fclient, **trail;
- int sbytes, bytes;
+ int bytes;
INFO0("file serving thread started");
while (run_fserv)
@@ -275,7 +275,7 @@
}
/* Now try and send current chunk. */
- sbytes = format_generic_write_to_client (client);
+ format_generic_write_to_client (client);
if (client->con->error)
{
Modified: icecast/branches/kh/icecast/src/yp.c
===================================================================
--- icecast/branches/kh/icecast/src/yp.c 2005-07-07 13:24:35 UTC (rev 9553)
+++ icecast/branches/kh/icecast/src/yp.c 2005-07-09 02:17:56 UTC (rev 9554)
@@ -85,11 +85,12 @@
static rwlock_t yp_lock;
static mutex_t yp_pending_lock;
-volatile static struct yp_server *active_yps = NULL, *pending_yps = NULL;
+static volatile struct yp_server *active_yps = NULL, *pending_yps = NULL;
static volatile int yp_update = 0;
static int yp_running;
static time_t now;
static thread_type *yp_thread;
+static volatile unsigned client_limit = 0;
static void *yp_update_thread(void *arg);
static void add_yp_info (ypdata_t *yp, void *info, int type);
@@ -215,6 +216,7 @@
server->remove = 1;
server = server->next;
}
+ client_limit = config->client_limit;
/* for each yp url in config, check to see if one exists
if not, then add it. */
for (i=0 ; i < config->num_yp_directories; i++)
@@ -387,10 +389,9 @@
static unsigned do_yp_touch (ypdata_t *yp, char *s, unsigned len)
{
- unsigned listeners = 0;
+ unsigned listeners = 0, max_listeners = 1;
char *val, *artist, *title;
int ret;
- char *max_listeners;
artist = (char *)stats_get_value (yp->mount, "artist");
title = (char *)stats_get_value (yp->mount, "title");
@@ -422,12 +423,15 @@
listeners = atoi (val);
free (val);
}
- max_listeners = stats_get_value (yp->mount, "max_listeners");
- if (max_listeners == NULL || strcmp (max_listeners, "unlimited") == 0)
+ val = stats_get_value (yp->mount, "max_listeners");
+ if (val == NULL || strcmp (val, "unlimited") == 0)
{
- free (max_listeners);
- max_listeners = (char *)stats_get_value (NULL, "client_limit");
+ free (val);
+ max_listeners = client_limit;
}
+ else
+ max_listeners = atoi (val);
+
val = stats_get_value (yp->mount, "subtype");
if (val)
{
@@ -436,10 +440,9 @@
}
ret = snprintf (s, len, "action=touch&sid=%s&st=%s"
- "&listeners=%u&max_listeners=%s&stype=%s\r\n",
+ "&listeners=%u&max_listeners=%u&stype=%s\r\n",
yp->sid, yp->current_song, listeners, max_listeners, yp->subtype);
- free (max_listeners);
if (ret >= (signed)len)
return ret+1; /* space required for above text and nul*/
More information about the commits
mailing list