mirror of
https://github.com/postgres/postgres.git
synced 2025-11-10 17:42:29 +03:00
pg_clean_ascii(): escape bytes rather than lose them
Rather than replace each unprintable byte with a '?' character, replace it with a hex escape instead. The API now allocates a copy rather than modifying the input in place. Author: Jacob Champion <jchampion@timescale.com> Discussion: https://www.postgresql.org/message-id/CAAWbhmgsvHrH9wLU2kYc3pOi1KSenHSLAHBbCVmmddW6-mc_=w@mail.gmail.com
This commit is contained in:
@@ -2280,11 +2280,7 @@ retry1:
|
||||
*/
|
||||
if (strcmp(nameptr, "application_name") == 0)
|
||||
{
|
||||
char *tmp_app_name = pstrdup(valptr);
|
||||
|
||||
pg_clean_ascii(tmp_app_name);
|
||||
|
||||
port->application_name = tmp_app_name;
|
||||
port->application_name = pg_clean_ascii(valptr, 0);
|
||||
}
|
||||
}
|
||||
offset = valoffset + strlen(valptr) + 1;
|
||||
|
||||
@@ -12921,9 +12921,18 @@ assign_maintenance_io_concurrency(int newval, void *extra)
|
||||
static bool
|
||||
check_application_name(char **newval, void **extra, GucSource source)
|
||||
{
|
||||
/* Only allow clean ASCII chars in the application name */
|
||||
pg_clean_ascii(*newval);
|
||||
char *clean;
|
||||
|
||||
/* Only allow clean ASCII chars in the application name */
|
||||
clean = pg_clean_ascii(*newval, MCXT_ALLOC_NO_OOM);
|
||||
if (!clean)
|
||||
return false;
|
||||
|
||||
clean = guc_strdup(WARNING, clean);
|
||||
if (!clean)
|
||||
return false;
|
||||
|
||||
*newval = clean;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -12937,9 +12946,18 @@ assign_application_name(const char *newval, void *extra)
|
||||
static bool
|
||||
check_cluster_name(char **newval, void **extra, GucSource source)
|
||||
{
|
||||
/* Only allow clean ASCII chars in the cluster name */
|
||||
pg_clean_ascii(*newval);
|
||||
char *clean;
|
||||
|
||||
/* Only allow clean ASCII chars in the cluster name */
|
||||
clean = pg_clean_ascii(*newval, MCXT_ALLOC_NO_OOM);
|
||||
if (!clean)
|
||||
return false;
|
||||
|
||||
clean = guc_strdup(WARNING, clean);
|
||||
if (!clean)
|
||||
return false;
|
||||
|
||||
*newval = clean;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user