From 7ac939b609439cb9eb773514bc7105a23829cf7f Mon Sep 17 00:00:00 2001 From: disconnect3d Date: Fri, 31 Jan 2020 03:57:14 +0100 Subject: [PATCH] Fix wrong size argument to pg_strncasecmp This commit fixes a size parameter of `pg_strncasecmp` which compared a "string" literal with a variable by passing a size of 5 while the "string" literal has 6 bytes. This issue can be observed with the following query (where 'X' is any character other than 'g' and null byte): select json_to_tsvector('"abc"'::json, '"strinX"') Before this commit this query returns the `'abc':1` result instead of failing with the following error: wrong flag in flag array: "strinX" --- src/backend/utils/adt/jsonfuncs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/backend/utils/adt/jsonfuncs.c b/src/backend/utils/adt/jsonfuncs.c index 4f6fd0de02..6e33dfb2a2 100644 --- a/src/backend/utils/adt/jsonfuncs.c +++ b/src/backend/utils/adt/jsonfuncs.c @@ -5125,7 +5125,7 @@ parse_jsonb_index_flags(Jsonb *jb) pg_strncasecmp(v.val.string.val, "key", 3) == 0) flags |= jtiKey; else if (v.val.string.len == 6 && - pg_strncasecmp(v.val.string.val, "string", 5) == 0) + pg_strncasecmp(v.val.string.val, "string", 6) == 0) flags |= jtiString; else if (v.val.string.len == 7 && pg_strncasecmp(v.val.string.val, "numeric", 7) == 0) -- 2.23.0