Fix pool_send_severity_message() not to use uninitialized memory.
authorTatsuo Ishii <ishii@postgresql.org>
Thu, 15 Nov 2012 23:09:08 +0000 (08:09 +0900)
committerTatsuo Ishii <ishii@postgresql.org>
Thu, 15 Nov 2012 23:16:49 +0000 (08:16 +0900)
Reported in Bug#33's attached valgrind output:

==20875== Syscall param write(buf) points to uninitialised byte(s)
==20875==    at 0x52680D0: __write_nocancel (syscall-template.S:82)
==20875==    by 0x41CC49: pool_flush_it (pool_stream.c:436)
==20875==    by 0x41CCF8: pool_flush (pool_stream.c:496)
==20875==    by 0x417AE4: pool_send_severity_message (pool_process_query.c:1722)
==20875==    by 0x417C12: pool_send_error_message (pool_process_query.c:1608)
==20875==    by 0x4182A0: read_kind_from_backend (pool_process_query.c:3768)
==20875==    by 0x449098: ProcessBackendResponse (pool_proto_modules.c:2562)
==20875==    by 0x41B9C4: pool_process_query (pool_process_query.c:274)
==20875==    by 0x40B1DF: do_child (child.c:362)
==20875==    by 0x404BD4: fork_a_child (main.c:1243)
==20875==    by 0x40795B: main (main.c:661)
==20875==  Address 0x87cb243 is 275 bytes inside a block of size 8,192 alloc'd
==20875==    at 0x4C244E8: malloc (vg_replace_malloc.c:236)
==20875==    by 0x41CEF4: pool_open (pool_stream.c:68)
==20875==    by 0x40A7B2: do_accept (child.c:784)
==20875==    by 0x40AA2A: do_child (child.c:185)
==20875==    by 0x404BD4: fork_a_child (main.c:1243)
==20875==    by 0x40795B: main (main.c:661)

pool_process_query.c

index af84d40c48bde456d558bab1f571eb166968afe6..9a8594d7351b50c7f46b98e2a3552f0d4c30ab72 100644 (file)
@@ -1778,6 +1778,7 @@ void pool_send_severity_message(POOL_CONNECTION *frontend, int protoMajor,
                int sendlen;
 
                len = 0;
+               memset(data, 0, MAXDATA);
 
                pool_write(frontend, "E", 1);