1
0
mirror of https://gitlab.xiph.org/xiph/icecast-server.git synced 2024-09-22 04:15:54 -04:00

Merged update for file extension check

Closes: #2248
This commit is contained in:
Philipp Schafft 2016-03-27 18:09:53 +00:00
commit 6e2773a43d
2 changed files with 17 additions and 28 deletions

View File

@ -197,35 +197,23 @@ char *util_get_extension(const char *path) {
}
int util_check_valid_extension(const char *uri) {
int ret = 0;
char *p2;
const char *p2;
if (uri) {
p2 = strrchr(uri, '.');
if (p2) {
p2++;
if (strncmp(p2, "xsl", strlen("xsl")) == 0) {
/* Build the full path for the request, concatenating the webroot from the config.
** Here would be also a good time to prevent accesses like '../../../../etc/passwd' or somesuch.
*/
ret = XSLT_CONTENT;
}
if (strncmp(p2, "htm", strlen("htm")) == 0) {
/* Build the full path for the request, concatenating the webroot from the config.
** Here would be also a good time to prevent accesses like '../../../../etc/passwd' or somesuch.
*/
ret = HTML_CONTENT;
}
if (strncmp(p2, "html", strlen("html")) == 0) {
/* Build the full path for the request, concatenating the webroot from the config.
** Here would be also a good time to prevent accesses like '../../../../etc/passwd' or somesuch.
*/
ret = HTML_CONTENT;
}
if (!uri)
return UNKNOWN_CONTENT;
}
p2 = strrchr(uri, '.');
if (!p2)
return UNKNOWN_CONTENT;
p2++;
if (strcmp(p2, "xsl") == 0 || strcmp(p2, "xslt") == 0) {
return XSLT_CONTENT;
} else if (strcmp(p2, "htm") == 0 || strcmp(p2, "html") == 0) {
return HTML_CONTENT;
}
return ret;
return UNKNOWN_CONTENT;
}
static int hex(char c)

View File

@ -17,8 +17,9 @@
/* for FILE* */
#include <stdio.h>
#define XSLT_CONTENT 1
#define HTML_CONTENT 2
#define UNKNOWN_CONTENT 0
#define XSLT_CONTENT 1
#define HTML_CONTENT 2
#define READ_ENTIRE_HEADER 1
#define READ_LINE 0