mirror of
https://github.com/servalproject/serval-dna.git
synced 2025-03-21 19:35:21 +00:00
Fix case where eof mime boundary overlaps buffer boundary
This commit is contained in:
parent
2241a15e48
commit
7939a780fb
@ -1221,12 +1221,14 @@ static int http_request_reject_content(struct http_request *r)
|
||||
*/
|
||||
static int _skip_mime_boundary(struct http_request *r)
|
||||
{
|
||||
if (!_skip_literal(r, "--") || !_skip_literal(r, r->request_header.content_type.multipart_boundary))
|
||||
return 0;
|
||||
if (_skip_literal(r, "--") && _skip_crlf(r))
|
||||
return 2;
|
||||
if (_skip_crlf(r))
|
||||
return 1;
|
||||
if (_skip_literal(r, "--") && _skip_literal(r, r->request_header.content_type.multipart_boundary)){
|
||||
char *ptr = r->cursor;
|
||||
if (_skip_literal(r, "--") && _skip_crlf(r))
|
||||
return 2;
|
||||
r->cursor = ptr;
|
||||
if (_skip_crlf(r))
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1389,6 +1391,11 @@ static int http_request_parse_body_form_data(struct http_request *r)
|
||||
_commit(r);
|
||||
return http_request_form_data_start_part(r, b);
|
||||
}
|
||||
// if we hit the end of the buffer in the middle of the mime boundary, rewind to the crlf & wait for more data
|
||||
if (_run_out(r)){
|
||||
r->cursor = end_preamble;
|
||||
break;
|
||||
}
|
||||
if (!at_start) {
|
||||
r->cursor = end_preamble;
|
||||
_skip_any(r);
|
||||
@ -1533,6 +1540,11 @@ static int http_request_parse_body_form_data(struct http_request *r)
|
||||
_INVOKE_HANDLER_BUF_LEN(handle_mime_body, start, end_body); // excluding CRLF at end
|
||||
return http_request_form_data_start_part(r, b);
|
||||
}
|
||||
// if we hit the end of the buffer in the middle of the mime boundary, rewind to the crlf & wait for more data
|
||||
if (_run_out(r)){
|
||||
r->cursor = end_body;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (_end_of_content(r)) {
|
||||
IDEBUGF(r->debug, "Malformed HTTP %s form data part: missing end boundary", r->verb);
|
||||
|
@ -655,6 +655,29 @@ test_RhizomeInsert() {
|
||||
done
|
||||
}
|
||||
|
||||
doc_RhizomeInsertBoundaries="HTTP RESTful insert of various payload lengths"
|
||||
setup_RhizomeInsertBoundaries() {
|
||||
setup
|
||||
}
|
||||
test_RhizomeInsertBoundaries() {
|
||||
for n in `seq 1 10`
|
||||
do
|
||||
create_file file$n $((7200 + ($n * 50)))
|
||||
>manifest$n
|
||||
execute curl \
|
||||
--silent --show-error --write-out '%{http_code}' \
|
||||
--output file$n.manifest \
|
||||
--dump-header http.header$n \
|
||||
--basic --user harry:potter \
|
||||
--form "manifest=@manifest$n;type=rhizome/manifest;format=\"text+binarysig\"" \
|
||||
--form "payload=@file$n" \
|
||||
"http://$addr_localhost:$PORTA/restful/rhizome/insert"
|
||||
tfw_cat http.header$n file$n.manifest
|
||||
assertExitStatus == 0
|
||||
assertStdoutIs 201
|
||||
done
|
||||
}
|
||||
|
||||
doc_RhizomeInsertAnon="HTTP RESTful update anonymous Rhizome bundle"
|
||||
setup_RhizomeInsertAnon() {
|
||||
setup
|
||||
|
Loading…
x
Reference in New Issue
Block a user