Re: Application name patch - v3 - Mailing list pgsql-hackers

From Dave Page
Subject Re: Application name patch - v3
Date
Msg-id 937d27e10911260554lbe616e2xabff5c88aa658a30@mail.gmail.com
Whole thread Raw
In response to Re: Application name patch - v3  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: Application name patch - v3
List pgsql-hackers
On Wed, Nov 25, 2009 at 10:01 PM, Tom Lane <tgl@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


pgsql-hackers by date:

Previous
From: Robert Haas
Date:
Subject: Re: cvs chapters in our docs
Next
From: Tom Lane
Date:
Subject: Re: force index problem in 8.4.1