diff options
author | Christian Grothoff <christian@grothoff.org> | 2012-01-30 19:03:16 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2012-01-30 19:03:16 +0000 |
commit | f7982784f7732f420b3995b88cec5b6e2b7e74e7 (patch) | |
tree | e6a28d02aa0c44e5d5599c5f7f93414354b901e2 | |
parent | 29ad274096d4a8e2c4812c57db415c9b885767df (diff) | |
download | libmicrohttpd-f7982784f7732f420b3995b88cec5b6e2b7e74e7.tar.gz libmicrohttpd-f7982784f7732f420b3995b88cec5b6e2b7e74e7.zip |
fixing #2126
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | src/daemon/postprocessor.c | 27 | ||||
-rw-r--r-- | src/include/microhttpd.h | 2 |
3 files changed, 29 insertions, 4 deletions
@@ -1,3 +1,7 @@ | |||
1 | Mon Jan 30 20:02:34 CET 2012 | ||
2 | Fixed handling of garbage prior to first multipart boundary | ||
3 | (#2126). -woof | ||
4 | |||
1 | Fri Jan 27 11:00:43 CET 2012 | 5 | Fri Jan 27 11:00:43 CET 2012 |
2 | Fixed postprocessor failure for applications that enclosed boundary | 6 | Fixed postprocessor failure for applications that enclosed boundary |
3 | in quotes (#2120). -woof | 7 | in quotes (#2120). -woof |
diff --git a/src/daemon/postprocessor.c b/src/daemon/postprocessor.c index 966630d8..7b18c88a 100644 --- a/src/daemon/postprocessor.c +++ b/src/daemon/postprocessor.c | |||
@@ -39,6 +39,7 @@ enum PP_State | |||
39 | PP_Error, | 39 | PP_Error, |
40 | PP_Done, | 40 | PP_Done, |
41 | PP_Init, | 41 | PP_Init, |
42 | PP_NextBoundary, | ||
42 | 43 | ||
43 | /* url encoding-states */ | 44 | /* url encoding-states */ |
44 | PP_ProcessValue, | 45 | PP_ProcessValue, |
@@ -492,7 +493,8 @@ find_boundary (struct MHD_PostProcessor *pp, | |||
492 | } | 493 | } |
493 | if ((0 != memcmp ("--", buf, 2)) || (0 != memcmp (&buf[2], boundary, blen))) | 494 | if ((0 != memcmp ("--", buf, 2)) || (0 != memcmp (&buf[2], boundary, blen))) |
494 | { | 495 | { |
495 | pp->state = PP_Error; | 496 | if (pp->state != PP_Init) |
497 | pp->state = PP_Error; | ||
496 | return MHD_NO; /* expected boundary */ | 498 | return MHD_NO; /* expected boundary */ |
497 | } | 499 | } |
498 | /* remove boundary from buffer */ | 500 | /* remove boundary from buffer */ |
@@ -823,6 +825,25 @@ post_process_multipart (struct MHD_PostProcessor *pp, | |||
823 | pp->state = PP_Error; | 825 | pp->state = PP_Error; |
824 | return MHD_NO; | 826 | return MHD_NO; |
825 | case PP_Init: | 827 | case PP_Init: |
828 | /** | ||
829 | * Per RFC2046 5.1.1 NOTE TO IMPLEMENTORS, consume anything | ||
830 | * prior to the first multipart boundary: | ||
831 | * | ||
832 | * > There appears to be room for additional information prior | ||
833 | * > to the first boundary delimiter line and following the | ||
834 | * > final boundary delimiter line. These areas should | ||
835 | * > generally be left blank, and implementations must ignore | ||
836 | * > anything that appears before the first boundary delimiter | ||
837 | * > line or after the last one. | ||
838 | */ | ||
839 | if (MHD_NO == find_boundary (pp, | ||
840 | pp->boundary, | ||
841 | pp->blen, | ||
842 | &ioff, | ||
843 | PP_ProcessEntryHeaders, PP_Done)) | ||
844 | ++ioff; | ||
845 | break; | ||
846 | case PP_NextBoundary: | ||
826 | if (MHD_NO == find_boundary (pp, | 847 | if (MHD_NO == find_boundary (pp, |
827 | pp->boundary, | 848 | pp->boundary, |
828 | pp->blen, | 849 | pp->blen, |
@@ -914,7 +935,7 @@ post_process_multipart (struct MHD_PostProcessor *pp, | |||
914 | pp->nlen, | 935 | pp->nlen, |
915 | &ioff, | 936 | &ioff, |
916 | PP_Nested_PerformMarking, | 937 | PP_Nested_PerformMarking, |
917 | PP_Init /* or PP_Error? */ )) | 938 | PP_NextBoundary /* or PP_Error? */ )) |
918 | { | 939 | { |
919 | if (pp->state == PP_Error) | 940 | if (pp->state == PP_Error) |
920 | return MHD_NO; | 941 | return MHD_NO; |
@@ -955,7 +976,7 @@ post_process_multipart (struct MHD_PostProcessor *pp, | |||
955 | pp->nested_boundary, | 976 | pp->nested_boundary, |
956 | pp->nlen, | 977 | pp->nlen, |
957 | PP_Nested_PerformCleanup, | 978 | PP_Nested_PerformCleanup, |
958 | PP_Init)) | 979 | PP_NextBoundary)) |
959 | { | 980 | { |
960 | if (pp->state == PP_Error) | 981 | if (pp->state == PP_Error) |
961 | return MHD_NO; | 982 | return MHD_NO; |
diff --git a/src/include/microhttpd.h b/src/include/microhttpd.h index 1ee99e99..e7a0aeaa 100644 --- a/src/include/microhttpd.h +++ b/src/include/microhttpd.h | |||
@@ -106,7 +106,7 @@ extern "C" | |||
106 | /** | 106 | /** |
107 | * Current version of the library. | 107 | * Current version of the library. |
108 | */ | 108 | */ |
109 | #define MHD_VERSION 0x00091200 | 109 | #define MHD_VERSION 0x00091201 |
110 | 110 | ||
111 | /** | 111 | /** |
112 | * MHD-internal return code for "YES". | 112 | * MHD-internal return code for "YES". |