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:24:29 +0000 (19:24 +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 d64ff29981f9ccb11aaa35cca361ff9fb7b3bcef..6dcdd3608bf8fdf8be6200e57a761a1e67dc0704 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
@@ -731,7 +731,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: