Fix maximum length of hostnames including domain name.
authorTatsuo Ishii <ishii@sraoss.co.jp>
Thu, 27 May 2021 10:15:46 +0000 (19:15 +0900)
committerTatsuo Ishii <ishii@sraoss.co.jp>
Thu, 27 May 2021 10:15:46 +0000 (19:15 +0900)
The maximum length of hostnames was 128, which is not incorrect.
Moreover there were multiple places where the maximum length of hostname is defined.
So create unified definition of it in libpcp_ext.h.

Discussion: https://www.pgpool.net/pipermail/pgpool-hackers/2021-May/003904.html

src/include/pcp/libpcp_ext.h
src/include/pool_config.h

index 7f8e9d96038efe699ee6b093aa32d86c28f8d275..9bcba4ad5000323dc4c70e5912b588b11c87a8e2 100644 (file)
@@ -4,7 +4,7 @@
  * pgpool: a language independent connection pool server for PostgreSQL
  * written by Tatsuo Ishii
  *
- * Copyright (c) 2003-2019     PgPool Global Development Group
+ * Copyright (c) 2003-2021     PgPool Global Development Group
  *
  * Permission to use, copy, modify, and distribute this software and
  * its documentation for any purpose and without fee is hereby
 #define SM_UNUSED              64
 #define SM_TTY                 64
 
+/*
+ * Maximum hostname length including domain name and "." including NULL
+ * terminate.
+ * https://en.wikipedia.org/wiki/Hostname#cite_note-Raymond,_Microsoft_devblog,_2012-3
+ */
+#define MAX_FDQN_HOSTNAME_LEN  254
+
 #define MAX_NUM_BACKENDS 128
 #define MAX_CONNECTION_SLOTS MAX_NUM_BACKENDS
-#define MAX_DB_HOST_NAMELEN     128
+#define MAX_DB_HOST_NAMELEN     MAX_FDQN_HOSTNAME_LEN
 #define MAX_PATH_LENGTH 256
 #define NAMEDATALEN 64
 
index d473dc1eaf7789aaf660f10da6a289e203922cb7..08c9b1c6d654e9a65c6cd09da8deb577db401056 100644 (file)
@@ -6,7 +6,7 @@
  * pgpool: a language independent connection pool server for PostgreSQL
  * written by Tatsuo Ishii
  *
- * Copyright (c) 2003-2019     PgPool Global Development Group
+ * Copyright (c) 2003-2021     PgPool Global Development Group
  *
  * Permission to use, copy, modify, and distribute this software and
  * its documentation for any purpose and without fee is hereby
@@ -33,7 +33,7 @@
 /*
  * watchdog
  */
-#define WD_MAX_HOST_NAMELEN (128)
+#define WD_MAX_HOST_NAMELEN MAX_FDQN_HOSTNAME_LEN
 #define WD_MAX_NODE_NAMELEN (WD_MAX_HOST_NAMELEN + POOLCONFIG_MAXPORTLEN + sizeof(((struct utsname *)NULL)->sysname) + sizeof(((struct utsname *)NULL)->nodename) + 3)
 #define WD_MAX_PATH_LEN (128)
 #define MAX_WATCHDOG_NUM (128)