PATCH: Fix wrong size argument to pg_strncasecmp

From: Dominik Czarnota <dominik(dot)b(dot)czarnota(at)gmail(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: PATCH: Fix wrong size argument to pg_strncasecmp
Date: 2020-01-31 03:18:09
Message-ID: CABEVAa1dU0mDCAfaT8WF2adVXTDsLVJy_izotg6ze_hh-cn8qQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hello,

Please find a one-liner patch in the attachment.

This patch 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 patch this query returns the `'abc':1` result instead of
failing with the following error:

wrong flag in flag array: "strinX"

By the way, the `strncasecmp` usages around the fixed line could use
`strcasecmp` which doesn't accept the `size_t n` argument.

---
Regards,
Disconnect3d

Attachment Content-Type Size
0001-Fix-wrong-size-argument-to-pg_strncasecmp.patch application/octet-stream 1.4 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Thomas Munro 2020-01-31 04:33:18 Re: Tweaking DSM and DSA limits
Previous Message Michael Paquier 2020-01-31 02:47:01 Re: Proposal: Add more compile-time asserts to expose inconsistencies.