convert_string_datum() says:

                /*
                 * Note: originally we guessed at a suitable output buffer 
size, and
                 * only needed to call strxfrm twice if our guess was too small.
                 * However, it seems that some versions of Solaris have buggy 
strxfrm
                 * that can write past the specified buffer length in that 
scenario.
                 * So, do it the dumb way for portability.

That arrived in commit 59d9a37, and I think this is the background:
http://www.postgresql.org/message-id/flat/3224.1020394...@sss.pgh.pa.us

PostgreSQL 9.5 adds a strxfrm() call in bttext_abbrev_convert(), which does
not account for the Solaris bug.  I wish to determine whether that bug is
still relevant today.  If you have access to Solaris with the is_IS.ISO8859-1
locale installed (or root access to install it), please compile and run the
attached test program on each Solaris version you have available.  Reply here
with the program's output.  I especially need a report from Solaris 10, but
reports from older and newer versions are valuable.  Thanks.


Here is the output on OmniOS r151006, which does not have the bug:

SunOS ip-10-152-178-106.ec2.internal 5.11 omnios-b281e50 i86pc i386 i86xpv
locale "is_IS.ISO8859-1": strxfrm returned 212; last modified byte at 58 (0x0)
locale "is_IS.ISO8859-1": strxfrm returned 212; last modified byte at 58 (0x0)
locale "": strxfrm returned 264; last modified byte at 58 (0x0)
#include <locale.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

void t(const char *locale, int canary)
{
    char buf[1024];
    size_t ret;
    int i;

    if (setlocale(LC_ALL, locale) == NULL)
        printf("setlocale(\"%s\") failed\n", locale);
    memset(buf, canary, sizeof(buf)); buf[0] = canary - 1;
    ret = strxfrm(buf + 1, "pg_amop_opc_strategy_index", 58);

    for (i = sizeof(buf) - 1; i >= 0 && buf[i] == canary; --i)
        ;
    printf("locale \"%s\": strxfrm returned %d; last modified byte at %d 
(0x%hhx)\n",
           locale, (int) ret, i, buf[i]);
}

int main(int argc, char **argv)
{
    system("uname -a");
    t("is_IS.ISO8859-1", 0x7F);
    t("is_IS.ISO8859-1", 0x7E);
    t("", 0x7F);
    return 0;
}
-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to