projects
/
yaz-moved-to-github.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
33d0d21
)
HTTP decoding: allow blanks in URL paths YAZ-700
author
Adam Dickmeiss
<adam@indexdata.dk>
Sat, 5 Oct 2013 14:30:42 +0000
(16:30 +0200)
committer
Adam Dickmeiss
<adam@indexdata.dk>
Sat, 5 Oct 2013 14:30:42 +0000
(16:30 +0200)
src/http.c
patch
|
blob
|
history
diff --git
a/src/http.c
b/src/http.c
index
378d145
..
642c3ad
100644
(file)
--- a/
src/http.c
+++ b/
src/http.c
@@
-507,9
+507,9
@@
int yaz_decode_http_request(ODR o, Z_HTTP_Request **hr_p)
Z_HTTP_Request *hr = (Z_HTTP_Request *) odr_malloc(o, sizeof(*hr));
const char *buf = o->op->buf;
int size = o->op->size;
Z_HTTP_Request *hr = (Z_HTTP_Request *) odr_malloc(o, sizeof(*hr));
const char *buf = o->op->buf;
int size = o->op->size;
+ int lspace = 0;
*hr_p = hr;
*hr_p = hr;
-
/* method .. */
for (i = 0; buf[i] != ' '; i++)
if (i >= size-5 || i > 30)
/* method .. */
for (i = 0; buf[i] != ' '; i++)
if (i >= size-5 || i > 30)
@@
-518,28
+518,21
@@
int yaz_decode_http_request(ODR o, Z_HTTP_Request **hr_p)
return 0;
}
hr->method = odr_strdupn(o, buf, i);
return 0;
}
hr->method = odr_strdupn(o, buf, i);
- /* path */
- po = i+1;
- for (i = po; buf[i] != ' '; i++)
- if (i >= size-5)
- {
- o->error = OHTTP;
- return 0;
- }
- hr->path = odr_strdupn(o, buf + po, i - po);
- /* HTTP version */
- i++;
- if (i > size-5 || memcmp(buf+i, "HTTP/", 5))
+ po = ++i;
+ while (i < size && !strchr("\r\n", buf[i]))
+ {
+ if (buf[i] == ' ')
+ lspace = i;
+ i++;
+ }
+ if (!lspace || i >= size || lspace >= size - 5 ||
+ memcmp(buf + lspace + 1, "HTTP/", 5))
{
o->error = OHTTP;
return 0;
}
{
o->error = OHTTP;
return 0;
}
- i+= 5;
- po = i;
- while (i < size && !strchr("\r\n", buf[i]))
- i++;
- hr->version = odr_strdupn(o, buf + po, i - po);
- /* headers */
+ hr->path = odr_strdupn(o, buf + po, lspace - po);
+ hr->version = odr_strdupn(o, buf + lspace + 6, i - (lspace + 6));
if (i < size-1 && buf[i] == '\r')
i++;
if (buf[i] != '\n')
if (i < size-1 && buf[i] == '\r')
i++;
if (buf[i] != '\n')
@@
-547,6
+540,7
@@
int yaz_decode_http_request(ODR o, Z_HTTP_Request **hr_p)
o->error = OHTTP;
return 0;
}
o->error = OHTTP;
return 0;
}
+ /* headers */
return decode_headers_content(o, i, &hr->headers,
&hr->content_buf, &hr->content_len);
}
return decode_headers_content(o, i, &hr->headers,
&hr->content_buf, &hr->content_len);
}