Fix ancient bug of pool_unread.
authorTatsuo Ishii <ishii@postgresql.org>
Tue, 15 Aug 2017 01:25:35 +0000 (10:25 +0900)
committerTatsuo Ishii <ishii@postgresql.org>
Tue, 15 Aug 2017 01:25:35 +0000 (10:25 +0900)
When realloc() is called in pool_unread(), it did not update the
buffer size.  This could cause variety of memory corruption and
unexpected data reading from backend. The reason why we did not found
that is, probably recently Pgpool-II starts extensively to use
pool_unread().

src/utils/pool_stream.c

index 2f8d2f2732818efef93b75b82ad2fd26165a0c05..f0f31d31f85da907d7092073e01f43cac995d3da 100644 (file)
@@ -1023,6 +1023,7 @@ int pool_unread(POOL_CONNECTION *cp, void *data, int len)
         MemoryContextSwitchTo(oldContext);
                
         cp->hp = p;
+               cp->bufsz = realloc_size;
        }
        if (cp->len != 0)
                memmove(p + len, cp->hp + cp->po, cp->len);