goto mfd_parse_brigade;
}
- next_ctx->param_name = "";
-
if (cd != NULL) {
s = apreq_header_attribute(cd, "name", 4,
&name, &nlen);
- if (s == APR_SUCCESS) {
- next_ctx->param_name
- = apr_pstrmemdup(pool, name, nlen);
+ if (s == APR_SUCCESS && nlen) {
+ next_ctx->param_name = apr_pstrmemdup(pool, name,
+ nlen);
+ }
+ else if (s != APREQ_ERROR_NOATTR) {
+ ctx->status = MFD_ERROR;
+ goto mfd_parse_brigade;
+ }
+ }
+ if (!next_ctx->param_name) {
+ const char *cid = apr_table_get(ctx->info,
+ "Content-ID");
+ if (cid) {
+ next_ctx->param_name = apr_pstrdup(pool, cid);
}
else {
- const char *cid = apr_table_get(ctx->info,
- "Content-ID");
- if (cid != NULL)
- next_ctx->param_name = apr_pstrdup(pool, cid);
+ next_ctx->param_name = "";
}
-
}
ctx->next_parser = apreq_parser_make(pool, ba, ct,
if (cd != NULL && strncmp(cd, "form-data", 9) == 0) {
s = apreq_header_attribute(cd, "name", 4, &name, &nlen);
- if (s != APR_SUCCESS) {
+ if (s != APR_SUCCESS || !nlen) {
ctx->status = MFD_ERROR;
goto mfd_parse_brigade;
}
s = apreq_header_attribute(cd, "filename",
8, &filename, &flen);
- if (s == APR_SUCCESS) {
+ if (s == APR_SUCCESS && flen) {
apreq_param_t *param;
param = apreq_param_make(pool, name, nlen,
ctx->status = MFD_UPLOAD;
goto mfd_parse_brigade;
}
+ else if (s != APREQ_ERROR_NOATTR) {
+ ctx->status = MFD_ERROR;
+ goto mfd_parse_brigade;
+ }
else {
ctx->param_name = apr_pstrmemdup(pool, name, nlen);
ctx->status = MFD_PARAM;
s = apreq_header_attribute(cd, "filename",
8, &filename, &flen);
- if (s != APR_SUCCESS || ctx->param_name == NULL) {
+ if (s != APR_SUCCESS || !flen || !ctx->param_name) {
ctx->status = MFD_ERROR;
goto mfd_parse_brigade;
}