util_xml.c revision 842ae4bd224140319ae7feec1872b93dfd491143
/* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "apr_xml.h"
#include "httpd.h"
#include "http_protocol.h"
#include "http_log.h"
#include "http_core.h"
#include "util_charset.h"
#include "util_xml.h"
/* used for reading input blocks */
#define READ_BLOCKSIZE 2048
{
int seen_eos;
char errbuf[200];
apr_size_t total_read = 0;
int result = HTTP_BAD_REQUEST;
seen_eos = 0;
total_read = 0;
do {
/* read the body, stuffing it into the parser */
if (status != APR_SUCCESS) {
goto read_error;
}
{
const char *data;
if (APR_BUCKET_IS_EOS(bucket)) {
seen_eos = 1;
break;
}
if (APR_BUCKET_IS_METADATA(bucket)) {
continue;
}
if (status != APR_SUCCESS) {
goto read_error;
}
total_read += len;
"XML request body is larger than the configured "
"limit of %lu", (unsigned long)limit_xml_body);
goto read_error;
}
if (status) {
goto parser_error;
}
}
} while (!seen_eos);
/* tell the parser that we're done */
if (status) {
/* Some parsers are stupid and return an error on blank documents. */
if (!total_read) {
return OK;
}
"XML parser error (at end). status=%d", status);
return HTTP_BAD_REQUEST;
}
#endif
return OK;
"XML Parser Error: %s", errbuf);
/* FALLTHRU */
/* make sure the parser is terminated */
/* Apache will supply a default error, plus the error log above. */
return result;
}