aboutsummaryrefslogtreecommitdiff
path: root/src/interfaces/libpq/fe-connect.c
diff options
context:
space:
mode:
authorDaniel Gustafsson <dgustafsson@postgresql.org>2023-03-30 10:53:15 +0200
committerDaniel Gustafsson <dgustafsson@postgresql.org>2023-03-30 10:53:15 +0200
commit2fe7a6df94e69a20c57f71a0592133684cf612da (patch)
tree31efb4dd541357a30c965c3dba4d9c39eb4997e0 /src/interfaces/libpq/fe-connect.c
parent261cf8962b8ce92ce62c47148bd72a2c2e3351b0 (diff)
downloadpostgresql-2fe7a6df94e69a20c57f71a0592133684cf612da.tar.gz
postgresql-2fe7a6df94e69a20c57f71a0592133684cf612da.zip
Fix pointer cast for seed calculation on 32-bit systems
The fallback seed for when pg_strong_random cannot generate a high quality seed mixes in the address of the conn object, but the cast failed to take the word size into consideration. Fix by casting to a uintptr_t instead. The seed calculation was added in 7f5b19817e. The code as it stood generated the following warning on mamba and lapwing in the buildfarm: fe-connect.c: In function 'libpq_prng_init': fe-connect.c:1048:11: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast] 1048 | rseed = ((uint64) conn) ^ | ^ Author: Hayato Kuroda <kuroda.hayato@fujitsu.com> Discussion: https://postgr.es/m/TYAPR01MB58665250EDCD551CCA9AD117F58E9@TYAPR01MB5866.jpnprd01.prod.outlook.com
Diffstat (limited to 'src/interfaces/libpq/fe-connect.c')
-rw-r--r--src/interfaces/libpq/fe-connect.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/interfaces/libpq/fe-connect.c b/src/interfaces/libpq/fe-connect.c
index a13ec16b321..bb7347cb0c0 100644
--- a/src/interfaces/libpq/fe-connect.c
+++ b/src/interfaces/libpq/fe-connect.c
@@ -1045,7 +1045,7 @@ libpq_prng_init(PGconn *conn)
gettimeofday(&tval, NULL);
- rseed = ((uint64) conn) ^
+ rseed = ((uintptr_t) conn) ^
((uint64) getpid()) ^
((uint64) tval.tv_usec) ^
((uint64) tval.tv_sec);