Fix ancient bug of pool_unread.
authorTatsuo Ishii <ishii@postgresql.org>
Tue, 15 Aug 2017 01:35:22 +0000 (10:35 +0900)
committerTatsuo Ishii <ishii@postgresql.org>
Tue, 15 Aug 2017 01:35:22 +0000 (10:35 +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().

pool_stream.c

index de86bad70d18c419c17fb543638c87b54d935eea..701b1d12edd481e1d9770fdf37282730e838916b 100644 (file)
@@ -864,6 +864,7 @@ int pool_unread(POOL_CONNECTION *cp, void *data, int len)
                        return -1;
                }
                cp->hp = p;
+               cp->bufsz = realloc_size;
        }
        if (cp->len != 0)
                memmove(p + len, cp->hp + cp->po, cp->len);