Ignore:
Timestamp:
Jan 1, 2014, 12:47:38 AM (10 years ago)
Author:
Bruno Cornec
Message:
  • Update mindi-busybox to 1.21.1
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/3.2/mindi-busybox/networking/httpd_indexcgi.c

    r2725 r3232  
    3636 */
    3737
     38#define _GNU_SOURCE 1  /* for strchrnul */
    3839#include <sys/types.h>
    3940#include <sys/stat.h>
     
    222223    int odd;
    223224    DIR *dirp;
    224     char *QUERY_STRING;
    225 
    226     QUERY_STRING = getenv("QUERY_STRING");
    227     if (!QUERY_STRING
    228      || QUERY_STRING[0] != '/'
    229      || strstr(QUERY_STRING, "//")
    230      || strstr(QUERY_STRING, "/../")
    231      || strcmp(strrchr(QUERY_STRING, '/'), "/..") == 0
     225    char *location;
     226
     227    location = getenv("REQUEST_URI");
     228    if (!location)
     229        return 1;
     230
     231    /* drop URL arguments if any */
     232    strchrnul(location, '?')[0] = '\0';
     233
     234    if (location[0] != '/'
     235     || strstr(location, "//")
     236     || strstr(location, "/../")
     237     || strcmp(strrchr(location, '/'), "/..") == 0
    232238    ) {
    233239        return 1;
     
    235241
    236242    if (chdir("..")
    237      || (QUERY_STRING[1] && chdir(QUERY_STRING + 1))
     243     || (location[1] && chdir(location + 1))
    238244    ) {
    239245        return 1;
     
    272278        "<html><head><title>Index of ");
    273279    /* Guard against directories with &, > etc */
    274     fmt_html(QUERY_STRING);
     280    fmt_html(location);
    275281    fmt_str(
    276282        "</title>\n"
     
    279285        "<body>" "\n"
    280286        "<h1>Index of ");
    281     fmt_html(QUERY_STRING);
     287    fmt_html(location);
    282288    fmt_str(
    283289        "</h1>" "\n"
Note: See TracChangeset for help on using the changeset viewer.