diff options
Diffstat (limited to 'src/daemon')
-rw-r--r-- | src/daemon/postprocessor.c | 27 |
1 files changed, 24 insertions, 3 deletions
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; |