git.postgresql.org Git - postgresql.git/commitdiff

git projects / postgresql.git / commitdiff
? search:
summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 261cf89)
Fix pointer cast for seed calculation on 32-bit systems
2023年3月30日 08:53:15 +0000 (10:53 +0200)
2023年3月30日 08:53:15 +0000 (10:53 +0200)
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


diff --git a/src/interfaces/libpq/fe-connect.c b/src/interfaces/libpq/fe-connect.c
index a13ec16b3213bce07fc3a617e24c985901200524..bb7347cb0c0ab2e4a390387206de36b7ddfa223b 100644 (file)
--- 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);
This is the main PostgreSQL git repository.
RSS Atom

AltStyle によって変換されたページ (->オリジナル) /