diff options
author | Teodor Sigaev <teodor@sigaev.ru> | 2016-04-02 13:47:04 +0300 |
---|---|---|
committer | Teodor Sigaev <teodor@sigaev.ru> | 2016-04-02 13:47:04 +0300 |
commit | 80afb62db0f118f70367a357cef0509a11112ebb (patch) | |
tree | 08d2a437f93f159aaa901996b832eca2da43dbd5 /contrib/bloom/blutils.c | |
parent | c22650cd6450854e1a75064b698d7dcbb4a8821a (diff) | |
download | postgresql-80afb62db0f118f70367a357cef0509a11112ebb.tar.gz postgresql-80afb62db0f118f70367a357cef0509a11112ebb.zip |
Fixes in bloom contrib module
Looking at result of buildfarm member jaguarundi it seems to me that
BloomOptions isn't inited sometime, but I don't see yet how it's possible.
Nevertheless, check of signature length's is missed, so, add
a limit of it. Also add missed GenericXLogAbort() in case of already
deleted page in vacuum + minor code refactoring.
Diffstat (limited to 'contrib/bloom/blutils.c')
-rw-r--r-- | contrib/bloom/blutils.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/contrib/bloom/blutils.c b/contrib/bloom/blutils.c index b86f51fb825..f301f415ab2 100644 --- a/contrib/bloom/blutils.c +++ b/contrib/bloom/blutils.c @@ -177,7 +177,7 @@ myRand() /* * Compute x = (7^5 * x) mod (2^31 - 1) * without overflowing 31 bits: - * (2^31 - 1) = 127773 * (7^5) + 2836 + * (2^31 - 1) = 127773 * (7^5) + 2836 * From "Random number generators: good ones are hard to find", * Park and Miller, Communications of the ACM, vol. 31, no. 10, * October 1988, p. 1195. @@ -370,8 +370,11 @@ adjustBloomOptions(BloomOptions *opts) /* Default length of bloom filter is 5 of 16-bit integers */ if (opts->bloomLength <= 0) opts->bloomLength = 5; - else - opts->bloomLength = opts->bloomLength; + else if (opts->bloomLength > MAX_BLOOM_LENGTH) + ereport(ERROR, + (errcode(ERRCODE_INVALID_PARAMETER_VALUE), + errmsg("length of bloom signature (%d) is greater than maximum %d", + opts->bloomLength, MAX_BLOOM_LENGTH))); /* Check singnature length */ for (i = 0; i < INDEX_MAX_KEYS; i++) @@ -382,7 +385,7 @@ adjustBloomOptions(BloomOptions *opts) * with 2 bits default. */ if (opts->bitSize[i] <= 0 - || opts->bitSize[i] >= opts->bloomLength * sizeof(SignType)) + || opts->bitSize[i] >= opts->bloomLength * sizeof(SignType) * BITS_PER_BYTE) opts->bitSize[i] = 2; } } |