pespin has submitted this change. ( https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/43665?usp=email )
(
1 is the latest approved patch-set. No files were changed between the latest approved patch-set and the submitted one. )Change subject: HTTP2_Functions: Remove trailing \r\n from multipart data payload ......................................................................
HTTP2_Functions: Remove trailing \r\n from multipart data payload
Change-Id: I7348b8734e23e63e51b5b9c5234075ff073b96e1 --- M library/HTTP2_Functions.ttcn 1 file changed, 13 insertions(+), 2 deletions(-)
Approvals: laforge: Looks good to me, but someone else must approve Jenkins Builder: Verified fixeria: Looks good to me, approved
diff --git a/library/HTTP2_Functions.ttcn b/library/HTTP2_Functions.ttcn index 554b7eb..307938b 100644 --- a/library/HTTP2_Functions.ttcn +++ b/library/HTTP2_Functions.ttcn @@ -72,14 +72,25 @@ return HTTP2_multipart_part { var HTTP2_multipart_part part; var octetstring delim := char2oct("\r\n\r\n"); + var octetstring trail := char2oct("\r\n");
- /* 0..off is headers, off+lengthof(delim)..end is the data. */ + /* 0..off is headers, off+lengthof(delim)..end is the data. + * Furthermore, data contains an extra "\r\n" at the end. */ var integer off := f_strstr_oct(data, delim, 0); var octetstring header := substr(data, 0, off); off := off + lengthof(delim); + + /* Validate data trail: */ + if (lengthof(data) < lengthof(trail) or + substr(data, lengthof(data) - lengthof(trail), lengthof(trail)) != trail) { + Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, + log2str("Rx unexpected part data: ", data)); + + } + part := { headers := f_HTTP2_multipart_msg_parse_part_headers(header), - data := substr(data, off, lengthof(data) - off) + data := substr(data, off, lengthof(data) - lengthof(trail) - off) } return part; }