diff options
author | Heikki Linnakangas <heikki.linnakangas@iki.fi> | 2024-10-28 14:07:38 +0200 |
---|---|---|
committer | Heikki Linnakangas <heikki.linnakangas@iki.fi> | 2024-10-28 14:08:01 +0200 |
commit | 55327256a049e3926d4d1cda39a7bb5886cbe03c (patch) | |
tree | 7a64942fb98911816dbd4ffae255dbc44b99b1f9 /src | |
parent | acf49584e2165ded5396d107961b568fe8f5f954 (diff) | |
download | postgresql-55327256a049e3926d4d1cda39a7bb5886cbe03c.tar.gz postgresql-55327256a049e3926d4d1cda39a7bb5886cbe03c.zip |
Fix overflow in bsearch_arg() with more than INT_MAX elements
This was introduced in commit bfa2cee784, which replaced the old
bsearch_cmp() function we had in extended_stats.c with the current
implementation. The original discussion or commit message of
bfa2cee784 didn't mention where the new implementation came from, but
based on some googling, I'm guessing *BSD or libiberty, all of which
share this same code, with or without this fix.
Author: Ranier Vilela
Reviewed-by: Nathan Bossart
Backpatch-through: 14
Discussion: https://www.postgresql.org/message-id/CAEudQAp34o_8u6sGSVraLwuMv9F7T9hyHpePXHmRaxR2Aboi%2Bw%40mail.gmail.com
Diffstat (limited to 'src')
-rw-r--r-- | src/port/bsearch_arg.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/port/bsearch_arg.c b/src/port/bsearch_arg.c index 8849bdffd25..c9a11c9d6da 100644 --- a/src/port/bsearch_arg.c +++ b/src/port/bsearch_arg.c @@ -58,8 +58,8 @@ bsearch_arg(const void *key, const void *base0, void *arg) { const char *base = (const char *) base0; - int lim, - cmp; + size_t lim; + int cmp; const void *p; for (lim = nmemb; lim != 0; lim >>= 1) |