From 96502f1400fc0ac2f172acd3f073c15112c5f5d1 Mon Sep 17 00:00:00 2001 From: Tatsuo Ishii Date: Fri, 18 Mar 2022 20:52:07 +0900 Subject: [PATCH] Fix bug with pg_enc and pg_md5. When these commands are invoked with "-i" option (read username/password pairs from a file), it did not create proper entries in pool_passwd. This bug was introduced by the commit: https://git.postgresql.org/gitweb/?p=pgpool2.git;a=commit;h=441bde41767fe3bccad513735f946dd2dec5059b Bug reported in https://www.pgpool.net/mantisbt/view.php?id=747 --- src/tools/pgenc/pg_enc.c | 4 ++-- src/tools/pgmd5/pg_md5.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/tools/pgenc/pg_enc.c b/src/tools/pgenc/pg_enc.c index 988870cfb..e39ddafc1 100644 --- a/src/tools/pgenc/pg_enc.c +++ b/src/tools/pgenc/pg_enc.c @@ -5,7 +5,7 @@ * pgpool: a language independent connection pool server for PostgreSQL * written by Tatsuo Ishii * - * Copyright (c) 2003-2021 PgPool Global Development Group + * Copyright (c) 2003-2022 PgPool Global Development Group * * Permission to use, copy, modify, and distribute this software and * its documentation for any purpose and without fee is hereby @@ -372,7 +372,7 @@ process_input_file(char *conf_file, char *input_file, char *key, bool updatepass fprintf(stderr, "LINE#%02d: input exceeds maximum username length %d\n",line_count, MAX_USER_NAME_LEN); goto clear_buffer; } - strncpy(username, buf, sizeof(username) - 1); + strncpy(username, buf, pch - buf - 1); if (strlen(pch) >= sizeof(password)) { diff --git a/src/tools/pgmd5/pg_md5.c b/src/tools/pgmd5/pg_md5.c index 70f274615..25d36a4d2 100644 --- a/src/tools/pgmd5/pg_md5.c +++ b/src/tools/pgmd5/pg_md5.c @@ -5,7 +5,7 @@ * pgpool: a language independent connection pool server for PostgreSQL * written by Tatsuo Ishii * - * Copyright (c) 2003-2021 PgPool Global Development Group + * Copyright (c) 2003-2022 PgPool Global Development Group * * Permission to use, copy, modify, and distribute this software and * its documentation for any purpose and without fee is hereby @@ -273,7 +273,7 @@ update_pool_passwd_from_file(char *conf_file, char *input_file, bool md5auth) fprintf(stdout, "input exceeds maximum username length %d\n\n", MAX_USER_NAME_LEN); continue; } - strncpy(username, buf, sizeof(username) - 1); + strncpy(username, buf, pch - buf - 1); if (strlen(pch) >= sizeof(password)) { -- 2.39.5