dict_synonym.c: fix truncation of multibyte sequence - Mailing list pgsql-hackers

From Jeff Davis
Subject dict_synonym.c: fix truncation of multibyte sequence
Date
Msg-id 1101e1a3afbbabb503317069c40374b82e6f4cac.camel@j-davis.com
Whole thread
Responses Re: dict_synonym.c: fix truncation of multibyte sequence
List pgsql-hackers
If case_sensitive is false and str_tolower() changes the byte length of
the string, then outlen will be incorrect.

Fortunately, pnstrdup() also stops at a NUL terminator, so it will
never overrun; but if outlen is calculated to be too small, then it
could cause truncation. In any case, the input comes from a trusted
source (dictionary configuration), so it's not very serious.

The correct value of outlen is strlen(d->syn[cur].out). But it's only
ever used in one place, which is a call to pnstrdup(). Given that the
string is NUL-terminated anyway, it's easier to fix it by just changing
that to a pstrdup(). Patch attached, backpatch all the way.

Regards,
    Jeff Davis


Attachment

pgsql-hackers by date:

Previous
From: Andres Freund
Date:
Subject: Re: Row pattern recognition
Next
From: Chao Li
Date:
Subject: Re: Fix OAuth validator docs for error_detail on internal errors