aboutsummaryrefslogtreecommitdiffstats
path: root/package/uhttpd/src/uhttpd-utils.c
diff options
context:
space:
mode:
authorJo-Philipp Wich <jow@openwrt.org>2010-07-23 13:15:22 +0000
committerJo-Philipp Wich <jow@openwrt.org>2010-07-23 13:15:22 +0000
commitf589036a4facd028bf6d9ff669ee3b7e36e966f4 (patch)
treea6c7c52be230dae6d05eee1edb99a57e3cbf112e /package/uhttpd/src/uhttpd-utils.c
parenta608f942ad27ac16e9262e502c670eb3a5a1dff8 (diff)
downloadupstream-f589036a4facd028bf6d9ff669ee3b7e36e966f4.tar.gz
upstream-f589036a4facd028bf6d9ff669ee3b7e36e966f4.tar.bz2
upstream-f589036a4facd028bf6d9ff669ee3b7e36e966f4.zip
[package] uhttpd:
- fix a compile warning - support custom index file names - support custom error pages (or cgi handler) - add option to disable directory listings - add REDIRECT_STATUS for CGI requests, fixes php-cgi git-svn-id: svn://svn.openwrt.org/openwrt/trunk@22366 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'package/uhttpd/src/uhttpd-utils.c')
-rw-r--r--package/uhttpd/src/uhttpd-utils.c24
1 files changed, 20 insertions, 4 deletions
diff --git a/package/uhttpd/src/uhttpd-utils.c b/package/uhttpd/src/uhttpd-utils.c
index caa6b12bc6..60badf26df 100644
--- a/package/uhttpd/src/uhttpd-utils.c
+++ b/package/uhttpd/src/uhttpd-utils.c
@@ -464,6 +464,9 @@ struct path_info * uh_path_lookup(struct client *cl, const char *url)
int i = 0;
struct stat s;
+ /* back out early if url is undefined */
+ if ( url == NULL )
+ return NULL;
memset(path_phys, 0, sizeof(path_phys));
memset(path_info, 0, sizeof(path_info));
@@ -550,18 +553,31 @@ struct path_info * uh_path_lookup(struct client *cl, const char *url)
memcpy(buffer, path_phys, sizeof(buffer));
pathptr = &buffer[strlen(buffer)];
- for( i = 0; i < array_size(uh_index_files); i++ )
+ if( cl->server->conf->index_file )
{
- strncat(buffer, uh_index_files[i], sizeof(buffer));
+ strncat(buffer, cl->server->conf->index_file, sizeof(buffer));
if( !stat(buffer, &s) && (s.st_mode & S_IFREG) )
{
memcpy(path_phys, buffer, sizeof(path_phys));
memcpy(&p.stat, &s, sizeof(p.stat));
- break;
}
+ }
+ else
+ {
+ for( i = 0; i < array_size(uh_index_files); i++ )
+ {
+ strncat(buffer, uh_index_files[i], sizeof(buffer));
- *pathptr = 0;
+ if( !stat(buffer, &s) && (s.st_mode & S_IFREG) )
+ {
+ memcpy(path_phys, buffer, sizeof(path_phys));
+ memcpy(&p.stat, &s, sizeof(p.stat));
+ break;
+ }
+
+ *pathptr = 0;
+ }
}
p.root = docroot;