Fix uninitialized memory error.
authorTatsuo Ishii <ishii@sraoss.co.jp>
Wed, 3 Apr 2024 10:13:53 +0000 (19:13 +0900)
committerTatsuo Ishii <ishii@sraoss.co.jp>
Wed, 3 Apr 2024 10:23:20 +0000 (19:23 +0900)
It was reported that valgrind found several errors including an
uninitialized memory error in read_startup_packet. It allocates memory
for user name in a startup packet in case cancel or SSL request using
palloc, and later on the memory is used by pstrdup. Since memory
allocated by palloc is undefined, this should have been palloc0.

Bug reported by: Emond Papegaaij
Backpatch-through: v4.1
Discussion:
[pgpool-general: 9065] Re: Segmentation after switchover
https://www.pgpool.net/pipermail/pgpool-general/2024-April/009126.html

src/protocol/child.c

index d334dad3c15f3a352279c359b1228184df8ee8c3..9afdac88f3e457d1e4cd5084737e599fb8435c86 100644 (file)
@@ -5,7 +5,7 @@
  * pgpool: a language independent connection pool server for PostgreSQL
  * written by Tatsuo Ishii
  *
- * Copyright (c) 2003-2023     PgPool Global Development Group
+ * Copyright (c) 2003-2024     PgPool Global Development Group
  *
  * Permission to use, copy, modify, and distribute this software and
  * its documentation for any purpose and without fee is hereby
@@ -743,7 +743,7 @@ read_startup_packet(POOL_CONNECTION * cp)
                case 1234:                              /* cancel or SSL request */
                        /* set dummy database, user info */
                        sp->database = palloc0(1);
-                       sp->user = palloc(1);
+                       sp->user = palloc0(1);
                        break;
 
                default: