Commit aa869033 authored by Philipp Schafft's avatar Philipp Schafft 🦁

handle empty strings in config file better. Now empty strings are handled in:...

handle empty strings in config file better. Now empty strings are handled in: accesslog, errorlog, logdir, webroot, adminroot and hopefully all kinds of port. Feal free to reopen ticket if there are more that needs to be fixed. closes #1963

svn path=/icecast/trunk/icecast/; revision=19268
parent df9d738b
...@@ -457,9 +457,13 @@ static void _parse_root(xmlDocPtr doc, xmlNodePtr node, ...@@ -457,9 +457,13 @@ static void _parse_root(xmlDocPtr doc, xmlNodePtr node,
_parse_listen_socket(doc, node->xmlChildrenNode, configuration); _parse_listen_socket(doc, node->xmlChildrenNode, configuration);
} else if (xmlStrcmp (node->name, XMLSTR("port")) == 0) { } else if (xmlStrcmp (node->name, XMLSTR("port")) == 0) {
tmp = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1); tmp = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1);
configuration->port = atoi(tmp); if (tmp) {
configuration->listen_sock->port = atoi(tmp); configuration->port = atoi(tmp);
if (tmp) xmlFree(tmp); configuration->listen_sock->port = atoi(tmp);
xmlFree(tmp);
} else {
ICECAST_LOG_WARN("<port> must not be empty.");
}
} else if (xmlStrcmp (node->name, XMLSTR("bind-address")) == 0) { } else if (xmlStrcmp (node->name, XMLSTR("bind-address")) == 0) {
if (configuration->listen_sock->bind_address) if (configuration->listen_sock->bind_address)
xmlFree(configuration->listen_sock->bind_address); xmlFree(configuration->listen_sock->bind_address);
...@@ -829,8 +833,12 @@ static void _parse_relay(xmlDocPtr doc, xmlNodePtr node, ...@@ -829,8 +833,12 @@ static void _parse_relay(xmlDocPtr doc, xmlNodePtr node,
} }
else if (xmlStrcmp (node->name, XMLSTR("port")) == 0) { else if (xmlStrcmp (node->name, XMLSTR("port")) == 0) {
tmp = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1); tmp = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1);
relay->port = atoi(tmp); if (tmp) {
if(tmp) xmlFree(tmp); relay->port = atoi(tmp);
xmlFree(tmp);
} else {
ICECAST_LOG_WARN("<port> must not be empty.");
}
} }
else if (xmlStrcmp (node->name, XMLSTR("mount")) == 0) { else if (xmlStrcmp (node->name, XMLSTR("mount")) == 0) {
if (relay->mount) xmlFree (relay->mount); if (relay->mount) xmlFree (relay->mount);
...@@ -887,10 +895,14 @@ static void _parse_listen_socket(xmlDocPtr doc, xmlNodePtr node, ...@@ -887,10 +895,14 @@ static void _parse_listen_socket(xmlDocPtr doc, xmlNodePtr node,
if (xmlStrcmp (node->name, XMLSTR("port")) == 0) { if (xmlStrcmp (node->name, XMLSTR("port")) == 0) {
tmp = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1); tmp = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1);
if(configuration->port == 0) if (tmp) {
configuration->port = atoi(tmp); if(configuration->port == 0)
listener->port = atoi(tmp); configuration->port = atoi(tmp);
if(tmp) xmlFree(tmp); listener->port = atoi(tmp);
xmlFree(tmp);
} else {
ICECAST_LOG_WARN("<port> must not be empty.");
}
} }
else if (xmlStrcmp (node->name, XMLSTR("ssl")) == 0) { else if (xmlStrcmp (node->name, XMLSTR("ssl")) == 0) {
tmp = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1); tmp = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1);
...@@ -1031,8 +1043,12 @@ static void _parse_paths(xmlDocPtr doc, xmlNodePtr node, ...@@ -1031,8 +1043,12 @@ static void _parse_paths(xmlDocPtr doc, xmlNodePtr node,
if (configuration->base_dir) xmlFree(configuration->base_dir); if (configuration->base_dir) xmlFree(configuration->base_dir);
configuration->base_dir = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1); configuration->base_dir = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1);
} else if (xmlStrcmp (node->name, XMLSTR("logdir")) == 0) { } else if (xmlStrcmp (node->name, XMLSTR("logdir")) == 0) {
if (!(temp = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1))) {
ICECAST_LOG_WARN("<logdir> must not be empty.");
continue;
}
if (configuration->log_dir) xmlFree(configuration->log_dir); if (configuration->log_dir) xmlFree(configuration->log_dir);
configuration->log_dir = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1); configuration->log_dir = temp;
} else if (xmlStrcmp (node->name, XMLSTR("pidfile")) == 0) { } else if (xmlStrcmp (node->name, XMLSTR("pidfile")) == 0) {
if (configuration->pidfile) xmlFree(configuration->pidfile); if (configuration->pidfile) xmlFree(configuration->pidfile);
configuration->pidfile = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1); configuration->pidfile = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1);
...@@ -1049,14 +1065,22 @@ static void _parse_paths(xmlDocPtr doc, xmlNodePtr node, ...@@ -1049,14 +1065,22 @@ static void _parse_paths(xmlDocPtr doc, xmlNodePtr node,
if (configuration->cipher_list) xmlFree(configuration->cipher_list); if (configuration->cipher_list) xmlFree(configuration->cipher_list);
configuration->cipher_list = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1); configuration->cipher_list = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1);
} else if (xmlStrcmp (node->name, XMLSTR("webroot")) == 0) { } else if (xmlStrcmp (node->name, XMLSTR("webroot")) == 0) {
if (!(temp = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1))) {
ICECAST_LOG_WARN("<webroot> must not be empty.");
continue;
}
if (configuration->webroot_dir) xmlFree(configuration->webroot_dir); if (configuration->webroot_dir) xmlFree(configuration->webroot_dir);
configuration->webroot_dir = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1); configuration->webroot_dir = temp;
if(configuration->webroot_dir[strlen(configuration->webroot_dir)-1] == '/') if(configuration->webroot_dir[strlen(configuration->webroot_dir)-1] == '/')
configuration->webroot_dir[strlen(configuration->webroot_dir)-1] = 0; configuration->webroot_dir[strlen(configuration->webroot_dir)-1] = 0;
} else if (xmlStrcmp (node->name, XMLSTR("adminroot")) == 0) { } else if (xmlStrcmp (node->name, XMLSTR("adminroot")) == 0) {
if (!(temp = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1))) {
ICECAST_LOG_WARN("<adminroot> must not be empty.");
continue;
}
if (configuration->adminroot_dir) if (configuration->adminroot_dir)
xmlFree(configuration->adminroot_dir); xmlFree(configuration->adminroot_dir);
configuration->adminroot_dir = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1); configuration->adminroot_dir = (char *)temp;
if(configuration->adminroot_dir[strlen(configuration->adminroot_dir)-1] == '/') if(configuration->adminroot_dir[strlen(configuration->adminroot_dir)-1] == '/')
configuration->adminroot_dir[strlen(configuration->adminroot_dir)-1] = 0; configuration->adminroot_dir[strlen(configuration->adminroot_dir)-1] = 0;
} else if (xmlStrcmp (node->name, XMLSTR("alias")) == 0) { } else if (xmlStrcmp (node->name, XMLSTR("alias")) == 0) {
...@@ -1101,16 +1125,25 @@ static void _parse_paths(xmlDocPtr doc, xmlNodePtr node, ...@@ -1101,16 +1125,25 @@ static void _parse_paths(xmlDocPtr doc, xmlNodePtr node,
static void _parse_logging(xmlDocPtr doc, xmlNodePtr node, static void _parse_logging(xmlDocPtr doc, xmlNodePtr node,
ice_config_t *configuration) ice_config_t *configuration)
{ {
char *tmp;
do { do {
if (node == NULL) break; if (node == NULL) break;
if (xmlIsBlankNode(node)) continue; if (xmlIsBlankNode(node)) continue;
if (xmlStrcmp (node->name, XMLSTR("accesslog")) == 0) { if (xmlStrcmp (node->name, XMLSTR("accesslog")) == 0) {
if (!(tmp = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1))) {
ICECAST_LOG_WARN("<accesslog> must not be empty.");
continue;
}
if (configuration->access_log) xmlFree(configuration->access_log); if (configuration->access_log) xmlFree(configuration->access_log);
configuration->access_log = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1); configuration->access_log = tmp;
} else if (xmlStrcmp (node->name, XMLSTR("errorlog")) == 0) { } else if (xmlStrcmp (node->name, XMLSTR("errorlog")) == 0) {
if (!(tmp = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1))) {
ICECAST_LOG_WARN("<errorlog> must not be empty.");
continue;
}
if (configuration->error_log) xmlFree(configuration->error_log); if (configuration->error_log) xmlFree(configuration->error_log);
configuration->error_log = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1); configuration->error_log = tmp;
} else if (xmlStrcmp (node->name, XMLSTR("playlistlog")) == 0) { } else if (xmlStrcmp (node->name, XMLSTR("playlistlog")) == 0) {
if (configuration->playlist_log) xmlFree(configuration->playlist_log); if (configuration->playlist_log) xmlFree(configuration->playlist_log);
configuration->playlist_log = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1); configuration->playlist_log = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment