[xiph-commits] r9124 - icecast/branches/kh/icecast/src
karl at motherfish-iii.xiph.org
karl at motherfish-iii.xiph.org
Thu Apr 7 10:53:30 PDT 2005
Author: karl
Date: 2005-04-07 10:53:28 -0700 (Thu, 07 Apr 2005)
New Revision: 9124
Modified:
icecast/branches/kh/icecast/src/auth_url.c
icecast/branches/kh/icecast/src/source.c
Log:
fix null dereference, and allow for the xml to state the HTTP header that
confirms a listener as authenticated
Modified: icecast/branches/kh/icecast/src/auth_url.c
===================================================================
--- icecast/branches/kh/icecast/src/auth_url.c 2005-04-07 16:01:23 UTC (rev 9123)
+++ icecast/branches/kh/icecast/src/auth_url.c 2005-04-07 17:53:28 UTC (rev 9124)
@@ -73,6 +73,8 @@
char *stream_end;
char *username;
char *password;
+ char *auth_header;
+ int auth_header_len;
CURL *handle;
char errormsg [CURL_ERROR_SIZE];
} auth_url;
@@ -96,8 +98,13 @@
unsigned bytes = size * nmemb;
client_t *client = auth_user->client;
- if (client && strncasecmp (ptr, "icecast-auth-user: 1\r\n", 22) == 0)
- client->authenticated = 1;
+ if (client)
+ {
+ auth_t *auth = client->auth;
+ auth_url *url = auth->state;
+ if (strncasecmp (ptr, url->auth_header, url->auth_header_len) == 0)
+ client->authenticated = 1;
+ }
return (int)bytes;
}
@@ -303,6 +310,7 @@
authenticator->stream_end = url_stream_end;
url_info = calloc(1, sizeof(auth_url));
+ url_info->auth_header = strdup ("icecast-auth-user: 1\r\n");
while(options) {
if(!strcmp(options->name, "username"))
@@ -317,6 +325,11 @@
url_info->stream_start = strdup (options->value);
if(!strcmp(options->name, "end"))
url_info->stream_end = strdup (options->value);
+ if(!strcmp(options->name, "header"))
+ {
+ free (url_info->auth_header);
+ url_info->auth_header = strdup (options->value);
+ }
options = options->next;
}
url_info->handle = curl_easy_init ();
@@ -326,6 +339,9 @@
free (authenticator);
return -1;
}
+ if (url_info->auth_header)
+ url_info->auth_header_len = strlen (url_info->auth_header);
+
curl_easy_setopt (url_info->handle, CURLOPT_HEADERFUNCTION, handle_returned_header);
curl_easy_setopt (url_info->handle, CURLOPT_WRITEFUNCTION, handle_returned_data);
curl_easy_setopt (url_info->handle, CURLOPT_WRITEDATA, url_info->handle);
Modified: icecast/branches/kh/icecast/src/source.c
===================================================================
--- icecast/branches/kh/icecast/src/source.c 2005-04-07 16:01:23 UTC (rev 9123)
+++ icecast/branches/kh/icecast/src/source.c 2005-04-07 17:53:28 UTC (rev 9124)
@@ -1019,6 +1019,10 @@
source->no_mount = mountinfo->no_mount;
source->hidden = mountinfo->hidden;
+ if (mountinfo->auth)
+ stats_event (source->mount, "authenticator", mountinfo->auth->type);
+ else
+ stats_event (source->mount, "authenticator", NULL);
if (mountinfo->fallback_mount)
{
free (source->fallback_mount);
@@ -1128,8 +1132,6 @@
else
stats_event (source->mount, "on-demand", NULL);
- stats_event (source->mount, "authenticator", mountinfo->auth->type);
-
DEBUG1 ("max listeners to %d", source->max_listeners);
DEBUG1 ("queue size to %u", source->queue_size_limit);
DEBUG1 ("burst size to %u", source->burst_size);
More information about the commits
mailing list