Fix buffer overrun issue with MySQL

`Vec::reserve` ensures that `self.capacity() >= self.len() +
additional`, not `self.capacity() >= original_capacity + additional`. If
we don't set the length before this call, we aren't necessarily actually
allocating to be the size we want to be, and risk a buffer overrun.
This commit is contained in:
Sean Griffin 2017-02-09 14:06:31 -05:00
parent 08df5fa363
commit a32afd94b5

View File

@ -155,6 +155,7 @@ impl BindData {
debug_assert!(truncated_amount > 0, "output buffers were invalidated \
without calling `mysql_stmt_bind_result`");
self.bytes.set_len(offset);
self.bytes.reserve(truncated_amount);
self.bytes.set_len(self.length as usize);