post form parsing fix retry as new boundary start needed after mismatching boundary
authorAndy Green <andy@warmcat.com>
Tue, 4 Oct 2016 00:24:00 +0000 (08:24 +0800)
committerAndy Green <andy@warmcat.com>
Tue, 4 Oct 2016 00:26:17 +0000 (08:26 +0800)
https://github.com/warmcat/libwebsockets/issues/641

lib/server.c

index 78a81dae718001dc7e409b2626d27917fdbf11e6..cc67e73b0fdccdd81a4258989736f71097c5a3fb 100644 (file)
@@ -2288,6 +2288,7 @@ lws_urldecode_s_process(struct lws_urldecode_stateful *s, const char *in, int le
                /* states for multipart / mime style */
 
                case MT_LOOK_BOUND_IN:
+retry_as_first:
                        if (*in == s->mime_boundary[s->mp] &&
                            s->mime_boundary[s->mp]) {
                                in++;
@@ -2314,8 +2315,11 @@ lws_urldecode_s_process(struct lws_urldecode_stateful *s, const char *in, int le
                                n = 0;
                                if (!s->boundary_real_crlf)
                                        n = 2;
+
                                memcpy(s->out + s->pos, s->mime_boundary + n, s->mp - n);
                                s->pos += s->mp;
+                               s->mp = 0;
+                               goto retry_as_first;
                        }
 
                        s->out[s->pos++] = *in;