mirror of
https://github.com/openssl/openssl.git
synced 2025-01-18 13:44:20 +08:00
For -WWW, fix test for ".." directory references (and avoid warning for
index -1).
This commit is contained in:
parent
4fea8145e2
commit
5d3ab9b096
@ -1423,20 +1423,34 @@ static int www_body(char *hostname, int s, unsigned char *context)
|
|||||||
{
|
{
|
||||||
BIO *file;
|
BIO *file;
|
||||||
char *p,*e;
|
char *p,*e;
|
||||||
static char *text="HTTP/1.0 200 ok\r\n"
|
static char *text="HTTP/1.0 200 ok\r\nContent-type: text/plain\r\n\r\n";
|
||||||
"Content-type: text/plain\r\n\r\n";
|
|
||||||
|
|
||||||
/* skip the '/' */
|
/* skip the '/' */
|
||||||
p= &(buf[5]);
|
p= &(buf[5]);
|
||||||
dot=0;
|
|
||||||
|
dot = 1;
|
||||||
for (e=p; *e != '\0'; e++)
|
for (e=p; *e != '\0'; e++)
|
||||||
{
|
{
|
||||||
if (e[0] == ' ') break;
|
if (e[0] == ' ')
|
||||||
if ( (e[0] == '.') &&
|
break;
|
||||||
(strncmp(&(e[-1]),"/../",4) == 0))
|
|
||||||
dot=1;
|
switch (dot)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
dot = (e[0] == '/') ? 1 : 0;
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
dot = (e[0] == '.') ? 2 : 0;
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
dot = (e[0] == '.') ? 3 : 0;
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
dot = (e[0] == '/') ? -1 : 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
dot = (dot == 3) || (dot == -1); /* filename contains ".." component */
|
||||||
|
|
||||||
if (*e == '\0')
|
if (*e == '\0')
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user