1
0
Fork 0
mirror of https://github.com/warmcat/libwebsockets.git synced 2025-03-09 00:00:04 +01:00

http: client multipart: caulate remaining length correctly

The current position is understood to be in *p, but for the remaining length
calculation we are wrongly comparing to p...
This commit is contained in:
Andy Green 2020-04-16 12:46:49 +01:00
parent d5cb0c6aa3
commit 6e4eac2b80

View file

@ -1022,7 +1022,7 @@ lws_client_http_multipart(struct lws *wsi, const char *name,
assert(wsi->http.multipart);
if (!name) {
*p += lws_snprintf((char *)(*p), lws_ptr_diff(end, p),
*p += lws_snprintf((char *)(*p), lws_ptr_diff(end, *p),
"\xd\xa--%s--\xd\xa",
wsi->http.multipart_boundary);
@ -1030,22 +1030,22 @@ lws_client_http_multipart(struct lws *wsi, const char *name,
}
if (wsi->client_subsequent_mime_part)
*p += lws_snprintf((char *)(*p), lws_ptr_diff(end, p), "\xd\xa");
*p += lws_snprintf((char *)(*p), lws_ptr_diff(end, *p), "\xd\xa");
wsi->client_subsequent_mime_part = 1;
*p += lws_snprintf((char *)(*p), lws_ptr_diff(end, p), "--%s\xd\xa"
*p += lws_snprintf((char *)(*p), lws_ptr_diff(end, *p), "--%s\xd\xa"
"Content-Disposition: form-data; "
"name=\"%s\"",
wsi->http.multipart_boundary, name);
if (filename)
*p += lws_snprintf((char *)(*p), lws_ptr_diff(end, p),
*p += lws_snprintf((char *)(*p), lws_ptr_diff(end, *p),
"; filename=\"%s\"", filename);
if (content_type)
*p += lws_snprintf((char *)(*p), lws_ptr_diff(end, p), "\xd\xa"
*p += lws_snprintf((char *)(*p), lws_ptr_diff(end, *p), "\xd\xa"
"Content-Type: %s", content_type);
*p += lws_snprintf((char *)(*p), lws_ptr_diff(end, p), "\xd\xa\xd\xa");
*p += lws_snprintf((char *)(*p), lws_ptr_diff(end, *p), "\xd\xa\xd\xa");
return *p == end;
}