mirror of
https://gitlab.xiph.org/xiph/icecast-server.git
synced 2024-09-22 04:15:54 -04:00
fix a couple of corner cases wrt xslt files, make sure sockets are closed
and that the buffer is truncated to the correct length or else some junk chars may appear at the end. svn path=/icecast/branches/kh/icecast/; revision=9546
This commit is contained in:
parent
b8df676ca3
commit
60f05a3d2d
19
src/xslt.c
19
src/xslt.c
@ -156,7 +156,7 @@ void xslt_transform(xmlDocPtr doc, const char *xslfilename, client_t *client)
|
||||
xmlDocPtr res;
|
||||
xsltStylesheetPtr cur;
|
||||
xmlChar *string;
|
||||
int len;
|
||||
int len, problem = 0;
|
||||
|
||||
thread_mutex_lock(&xsltlock);
|
||||
cur = xslt_get_stylesheet(xslfilename);
|
||||
@ -171,20 +171,29 @@ void xslt_transform(xmlDocPtr doc, const char *xslfilename, client_t *client)
|
||||
|
||||
res = xsltApplyStylesheet(cur, doc, NULL);
|
||||
|
||||
xsltSaveResultToString (&string, &len, res, cur);
|
||||
if (xsltSaveResultToString (&string, &len, res, cur) < 0)
|
||||
problem = 1;
|
||||
thread_mutex_unlock(&xsltlock);
|
||||
if (string)
|
||||
if (problem == 0)
|
||||
{
|
||||
const char *http = "HTTP/1.0 200 OK\r\nContent-Type: text/html\r\nContent-Length: ";
|
||||
unsigned buf_len = strlen (http) + 20 + len;
|
||||
int buf_len = strlen (http) + 20 + len;
|
||||
|
||||
if (string == NULL)
|
||||
string = xmlStrdup ("");
|
||||
client->respcode = 200;
|
||||
client_set_queue (client, NULL);
|
||||
client->refbuf = refbuf_new (buf_len);
|
||||
snprintf (client->refbuf->data, buf_len, "%s%d\r\n\r\n%s", http, len, string);
|
||||
len = snprintf (client->refbuf->data, buf_len, "%s%d\r\n\r\n%s", http, len, string);
|
||||
client->refbuf->len = len;
|
||||
fserve_add_client (client, NULL);
|
||||
xmlFree (string);
|
||||
}
|
||||
else
|
||||
{
|
||||
WARN1 ("problem applying stylesheet \"%s\"", xslfilename);
|
||||
client_send_404 (client, "XSLT problem");
|
||||
}
|
||||
xmlFreeDoc(res);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user