diff options
author | Alexey Kopytov <Alexey.Kopytov@Sun.com> | 2009-07-28 22:44:28 +0400 |
---|---|---|
committer | Alexey Kopytov <Alexey.Kopytov@Sun.com> | 2009-07-28 22:44:28 +0400 |
commit | aacfd6ddb7bdea4842195fd944c07ffabd58f49d (patch) | |
tree | 85d54ad3e3765484d183f04758043d25edd5458d /sql/net_serv.cc | |
parent | a30451789453375e9d997d640a0c8f5361af5bee (diff) | |
parent | 53434623ffe50cc60567656601a405968eb2b132 (diff) | |
download | mariadb-git-aacfd6ddb7bdea4842195fd944c07ffabd58f49d.tar.gz |
Manual merge.
Diffstat (limited to 'sql/net_serv.cc')
-rw-r--r-- | sql/net_serv.cc | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/sql/net_serv.cc b/sql/net_serv.cc index 0a8720bae64..73892f31ccf 100644 --- a/sql/net_serv.cc +++ b/sql/net_serv.cc @@ -186,10 +186,12 @@ my_bool net_realloc(NET *net, size_t length) pkt_length = (length+IO_SIZE-1) & ~(IO_SIZE-1); /* We must allocate some extra bytes for the end 0 and to be able to - read big compressed blocks + read big compressed blocks + 1 safety byte since uint3korr() in + my_real_read() may actually read 4 bytes depending on build flags and + platform. */ if (!(buff= (uchar*) my_realloc((char*) net->buff, pkt_length + - NET_HEADER_SIZE + COMP_HEADER_SIZE, + NET_HEADER_SIZE + COMP_HEADER_SIZE + 1, MYF(MY_WME)))) { /* @todo: 1 and 2 codes are identical. */ @@ -921,6 +923,13 @@ my_real_read(NET *net, size_t *complen) #ifdef HAVE_COMPRESS if (net->compress) { + /* + The following uint3korr() may read 4 bytes, so make sure we don't + read unallocated or uninitialized memory. The right-hand expression + must match the size of the buffer allocated in net_realloc(). + */ + DBUG_ASSERT(net->where_b + NET_HEADER_SIZE + sizeof(uint32) <= + net->max_packet + NET_HEADER_SIZE + COMP_HEADER_SIZE + 1); /* If the packet is compressed then complen > 0 and contains the number of bytes in the uncompressed packet |