mirror of
https://github.com/boostorg/beast.git
synced 2025-08-05 07:44:35 +02:00
Safe treatment of zero-length string arguments in basic_fields:
This fixes a broken memcpy precondition when empty strings are passed as arguments to basic_fields member functions.
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
Version 159:
|
Version 159:
|
||||||
|
|
||||||
* Fix typo in release notes
|
* Fix typo in release notes
|
||||||
|
* Safe treatment of zero-length string arguments in basic_fields
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
@@ -110,6 +110,8 @@ to update to the latest Boost release.
|
|||||||
|
|
||||||
* ([issue 1030]) Fix big-endian websocket masking
|
* ([issue 1030]) Fix big-endian websocket masking
|
||||||
|
|
||||||
|
* Safe treatment of zero-length string arguments in basic_fields
|
||||||
|
|
||||||
[*API Changes]
|
[*API Changes]
|
||||||
|
|
||||||
* Remove unintended public members of
|
* Remove unintended public members of
|
||||||
|
@@ -272,8 +272,10 @@ writer(basic_fields const& f,
|
|||||||
template<class Allocator>
|
template<class Allocator>
|
||||||
basic_fields<Allocator>::
|
basic_fields<Allocator>::
|
||||||
value_type::
|
value_type::
|
||||||
value_type(field name,
|
value_type(
|
||||||
string_view sname, string_view value)
|
field name,
|
||||||
|
string_view sname,
|
||||||
|
string_view value)
|
||||||
: off_(static_cast<off_t>(sname.size() + 2))
|
: off_(static_cast<off_t>(sname.size() + 2))
|
||||||
, len_(static_cast<off_t>(value.size()))
|
, len_(static_cast<off_t>(value.size()))
|
||||||
, f_(name)
|
, f_(name)
|
||||||
@@ -285,8 +287,8 @@ value_type(field name,
|
|||||||
p[off_-1] = ' ';
|
p[off_-1] = ' ';
|
||||||
p[off_ + len_] = '\r';
|
p[off_ + len_] = '\r';
|
||||||
p[off_ + len_ + 1] = '\n';
|
p[off_ + len_ + 1] = '\n';
|
||||||
std::memcpy(p, sname.data(), sname.size());
|
sname.copy(p, sname.size());
|
||||||
std::memcpy(p + off_, value.data(), value.size());
|
value.copy(p + off_, value.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class Allocator>
|
template<class Allocator>
|
||||||
@@ -1226,7 +1228,7 @@ realloc_string(string_view& dest, string_view s)
|
|||||||
if(! s.empty())
|
if(! s.empty())
|
||||||
{
|
{
|
||||||
auto const p = a.allocate(s.size());
|
auto const p = a.allocate(s.size());
|
||||||
std::memcpy(p, s.data(), s.size());
|
s.copy(p, s.size());
|
||||||
dest = {p, s.size()};
|
dest = {p, s.size()};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1255,7 +1257,7 @@ realloc_target(
|
|||||||
{
|
{
|
||||||
auto const p = a.allocate(1 + s.size());
|
auto const p = a.allocate(1 + s.size());
|
||||||
p[0] = ' ';
|
p[0] = ' ';
|
||||||
std::memcpy(p + 1, s.data(), s.size());
|
s.copy(p + 1, s.size());
|
||||||
dest = {p, 1 + s.size()};
|
dest = {p, 1 + s.size()};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user