On Wed, Nov 25, 2009 at 10:01 PM, Tom Lane <t...@sss.pgh.pa.us> wrote:
> ISTM restricting the name to ASCII-only is the most reasonable tradeoff.
> Of course, as a speaker of English I may be a bit biased here --- but
> doing nothing about the issue doesn't seem acceptable.

OK - something like this? Should keep non-printable/control characters
out of logs too...

static const char *
assign_application_name(const char *newval, bool doit, GucSource source)
{
        /* Only allow clean ASCII chars in the application name */
        int x;

        char *repval = guc_malloc(ERROR, strlen(newval) + 1);
        repval[0] = 0;

        for (x=0; x<strlen(newval); x++)
        {
                if (newval[x] < 32 || newval[x] > 126)
                        repval[x] = '?';
                else
                        repval[x] = newval[x];
        }

        repval[x+1] = 0;
        return repval;
}


-- 
Dave Page
EnterpriseDB UK: http://www.enterprisedb.com

-- 
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