aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWolfgang Draxinger <Wolfgang.Draxinger@physik.uni-muenchen.de>2013-06-26 19:34:04 +0200
committerWolfgang Draxinger <Wolfgang.Draxinger@physik.uni-muenchen.de>2013-06-26 19:34:04 +0200
commitffa2fc800d92b40f4a128814ae55b121a7852e58 (patch)
tree0191049749a398225722172adcb780a2cb0a3c9d
parent6563dbb5655b409aabe9514f8844711634b0aff2 (diff)
downloadlitheweb-ffa2fc800d92b40f4a128814ae55b121a7852e58.tar.gz
litheweb-ffa2fc800d92b40f4a128814ae55b121a7852e58.tar.bz2
*grrr* last two days completely wasted because text editors fooled me by not showing CR and LF present and things I thought to be artifacts are actual data. At least I could fix it easily.
-rw-r--r--picohttp.c45
-rw-r--r--picohttp.h4
2 files changed, 34 insertions, 15 deletions
diff --git a/picohttp.c b/picohttp.c
index 4d9376c..50a864e 100644
--- a/picohttp.c
+++ b/picohttp.c
@@ -560,8 +560,8 @@ static void picohttpProcessContentType(
/* see RFC1521 regarding maximum length of boundary */
memset(req->query.multipartboundary, 0,
PICOHTTP_MULTIPARTBOUNDARY_MAX_LEN+1);
- memcpy(req->query.multipartboundary, "\r\n\r\n--", 6);
- strncpy(req->query.multipartboundary+6,
+ memcpy(req->query.multipartboundary, "\r\n--", 4);
+ strncpy(req->query.multipartboundary+4,
boundary + sizeof(PICOHTTP_STR_BOUNDARY)-1,
PICOHTTP_MULTIPARTBOUNDARY_MAX_LEN);
}
@@ -945,11 +945,13 @@ int16_t picohttpMultipartGetch(
* regarding line termination. <CR><LF> or just <LF>
* are accepted.
* However multipart boundaries are to start with
- * a [<CR>]<LF><CR><LF> sequence.
+ * a <CR><LF> sequence.
*/
mp->replay = 0;
if( '\r' == ch ) {
+ debug_printf("'CR'");
+ #if PICOHTTP_CRLFCRLF
if( '\n' == mp->req->query.prev_ch[1]
#if PICOHTTP_STRICT_CRLF_MULTIPART_BOUNDARY_PREFIX
&& '\r' == mp->req->query.prev_ch[2]
@@ -957,13 +959,17 @@ int16_t picohttpMultipartGetch(
) {
mp->replayhead =
mp->in_boundary = 2;
- } else {
+ } else
+ #endif
+ {
mp->replayhead =
mp->in_boundary = 0;
}
} else
if( '\n' == ch &&
'\r' == mp->req->query.prev_ch[1] ) {
+ debug_printf("'LF'");
+ #if PICOHTTP_CRLFCRLF
if( '\n' == mp->req->query.prev_ch[2]
#if PICOHTTP_STRICT_CRLF_MULTIPART_BOUNDARY_PREFIX
&& '\r' == mp->req->query.prev_ch[3]
@@ -971,21 +977,26 @@ int16_t picohttpMultipartGetch(
) {
mp->replayhead =
mp->in_boundary = 3;
- } else {
+ } else
+ #endif
+ {
mp->replayhead =
mp->in_boundary = 1;
}
} else
if( '-' == ch &&
'\n' == mp->req->query.prev_ch[1] &&
- '\r' == mp->req->query.prev_ch[2] &&
- '\n' == mp->req->query.prev_ch[3]
+ '\r' == mp->req->query.prev_ch[2]
+#if PICOHTTP_CRLFCRLF
+ && '\n' == mp->req->query.prev_ch[3]
#if PICOHTTP_STRICT_CRLF_MULTIPART_BOUNDARY_PREFIX
&& '\r' == mp->req->query.prev_ch[4]
#endif
+#endif
) {
+ debug_printf("'-'");
mp->replayhead =
- mp->in_boundary = 4;
+ mp->in_boundary = 2;
}
while( 0 <= ch ) {
@@ -1039,6 +1050,7 @@ int16_t picohttpMultipartGetch(
* is a nasty, convoluted state machine
*/
if( '\r' == ch ) {
+ #if PICOHTTP_CRLFCRLF
if( '\n' == mp->req->query.prev_ch[1]
#if PICOHTTP_STRICT_CRLF_MULTIPART_BOUNDARY_PREFIX
&& '\r' == mp->req->query.prev_ch[2]
@@ -1046,7 +1058,9 @@ int16_t picohttpMultipartGetch(
) {
mp->replay = mp->in_boundary - 3;
mp->in_boundary = 3;
- } else {
+ } else
+ #endif
+ {
mp->replay = mp->in_boundary - 1;
mp->in_boundary = 1;
}
@@ -1055,6 +1069,7 @@ int16_t picohttpMultipartGetch(
} else
if( '\n' == ch &&
'\r' == mp->req->query.prev_ch[1] ) {
+ #if PICOHTTP_CRLFCRLF
if( '\n' == mp->req->query.prev_ch[2]
#if PICOHTTP_STRICT_CRLF_MULTIPART_BOUNDARY_PREFIX
&& '\r' == mp->req->query.prev_ch[3]
@@ -1062,7 +1077,9 @@ int16_t picohttpMultipartGetch(
) {
mp->replay = mp->in_boundary - 4;
mp->in_boundary = 4;
- } else {
+ } else
+ #endif
+ {
mp->replay = mp->in_boundary - 2;
mp->in_boundary = 2;
}
@@ -1071,14 +1088,16 @@ int16_t picohttpMultipartGetch(
} else
if( '-' == ch &&
'\n' == mp->req->query.prev_ch[1] &&
- '\r' == mp->req->query.prev_ch[2] &&
- '\n' == mp->req->query.prev_ch[3]
+ '\r' == mp->req->query.prev_ch[2]
+ #if PICOHTTP_CRLFCRLF
+ && '\n' == mp->req->query.prev_ch[3]
#if PICOHTTP_STRICT_CRLF_MULTIPART_BOUNDARY_PREFIX
&& '\r' == mp->req->query.prev_ch[4]
#endif
+ #endif
) {
mp->replay = mp->in_boundary - 4;
- mp->in_boundary = 4;
+ mp->in_boundary = 2;
} else {
mp->replay = mp->in_boundary;
mp->in_boundary = 0;
diff --git a/picohttp.h b/picohttp.h
index faa54de..d7bccde 100644
--- a/picohttp.h
+++ b/picohttp.h
@@ -5,8 +5,8 @@
#include <stddef.h>
#include <stdint.h>
-/* max 70 for boundary + 6 chars for "<CR><LF>--" */
-#define PICOHTTP_MULTIPARTBOUNDARY_MAX_LEN 76
+/* max 70 for boundary + 4 chars for "<CR><LF>--" */
+#define PICOHTTP_MULTIPARTBOUNDARY_MAX_LEN 74
#define PICOHTTP_DISPOSITION_NAME_MAX 16
#define PICOHTTP_MAJORVERSION(x) ( (x & 0x7f00) >> 8 )