From: Yann Ylavic Date: Fri, 12 Nov 2021 21:47:09 +0000 (+0000) Subject: apreq: Sync r1894983 from libapreq. X-Git-Tag: 2.5.0-alpha2-ci-test-only~696 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=6c44dd11d551ffad1f0d9d3f8cbb065f202c844c;p=thirdparty%2Fapache%2Fhttpd.git apreq: Sync r1894983 from libapreq. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1894986 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/server/apreq_parser_multipart.c b/server/apreq_parser_multipart.c index 4242b7e9ebf..e4c4d71b91e 100644 --- a/server/apreq_parser_multipart.c +++ b/server/apreq_parser_multipart.c @@ -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 */