]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
apreq: Sync r1894983 from libapreq.
authorYann Ylavic <ylavic@apache.org>
Fri, 12 Nov 2021 21:47:09 +0000 (21:47 +0000)
committerYann Ylavic <ylavic@apache.org>
Fri, 12 Nov 2021 21:47:09 +0000 (21:47 +0000)
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1894986 13f79535-47bb-0310-9956-ffa450edef68

server/apreq_parser_multipart.c

index 4242b7e9ebf71a86d98a063cca922a96b44177bf..e4c4d71b91e41533ea8a53bf0eb175d8a15819ca 100644 (file)
@@ -220,17 +220,24 @@ struct mfd_ctx * create_multipart_context(const char *content_type,
 {
     apr_status_t s;
     apr_size_t blen;
-    struct mfd_ctx *ctx = apr_palloc(pool, sizeof *ctx);
-    char *ct = apr_pstrdup(pool, content_type);
+    struct mfd_ctx *ctx;
+    const char *attr;
+    char *buf;
 
-    ct = strchr(ct, ';');
-    if (ct == NULL)
+    attr = (content_type) ? strchr(content_type, ';') : NULL;
+    if (!attr)
         return NULL; /* missing semicolon */
 
-    *ct++ = 0;
-    s = apreq_header_attribute(ct, "boundary", 8,
-                               (const char **)&ctx->bdry, &blen);
+    ctx = apr_palloc(pool, sizeof *ctx);
+
+    attr++;
+    blen = strlen(attr) + 1;
+    buf = apr_palloc(pool, 4 + blen);
+    buf += 4;
+    memcpy(buf, attr, blen);
 
+    s = apreq_header_attribute(buf, "boundary", 8,
+                               (const char **)&ctx->bdry, &blen);
     if (s != APR_SUCCESS)
         return NULL; /* missing boundary */