]> granicus.if.org Git - pdns/commit
Ensure a valid range to string::assign() in PacketReader::xfrBlob()
authorRemi Gacogne <remi.gacogne@powerdns.com>
Fri, 7 Dec 2018 10:13:17 +0000 (11:13 +0100)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Mon, 10 Dec 2018 17:30:21 +0000 (18:30 +0100)
commitb4d358e79b23a6eb13680b13348e554da820fd89
treedc289fcb4d9c6ae67bfd960891b6b80f55787f32
parentdf6050fb0ee3ff33e6a8ad1a0091a3007586c87d
Ensure a valid range to string::assign() in PacketReader::xfrBlob()

In some cases we could have called:

std::string::assign(InputIterator first, InputIterator last)

with last < first, which is UB:

if the range specified by [first,last) is not valid, it causes undefined behavior

libstdc++ handles that gracefully by throwing an out-of-range exception
but libc++ tries to allocate a negative value of bytes, which in turns
triggers a request for a very large memory allocation, which fails.
pdns/dnsparser.cc