Skip to content

Commit c027624

Browse files
committed
Convert variable name to canonical spelling before checking for matches
in GUCArrayAdd/GUCArrayDelete. This prevents the multiple-entry bug exhibited by Frank Lupo 28-Jan-2003.
1 parent 7af352d commit c027624

File tree

1 file changed

+11
-1
lines changed
  • src/backend/utils/misc

1 file changed

+11
-1
lines changed

src/backend/utils/misc/guc.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* command, configuration file, and command line options.
66
* See src/backend/utils/misc/README for more information.
77
*
8-
* $Header: /cvsroot/pgsql/src/backend/utils/misc/guc.c,v 1.112 2003/01/27 23:55:38 momjian Exp $
8+
* $Header: /cvsroot/pgsql/src/backend/utils/misc/guc.c,v 1.113 2003/01/28 18:04:02 tgl Exp $
99
*
1010
* Copyright 2000 by PostgreSQL Global Development Group
1111
* Written by Peter Eisentraut <peter_e@gmx.net>.
@@ -2834,6 +2834,7 @@ ProcessGUCArray(ArrayType *array, GucSource source)
28342834
ArrayType *
28352835
GUCArrayAdd(ArrayType *array, const char *name, const char *value)
28362836
{
2837+
const char *varname;
28372838
Datum datum;
28382839
char *newval;
28392840
ArrayType *a;
@@ -2846,6 +2847,10 @@ GUCArrayAdd(ArrayType *array, const char *name, const char *value)
28462847
superuser() ? PGC_SUSET : PGC_USERSET,
28472848
PGC_S_SESSION, false, false);
28482849

2850+
/* convert name to canonical spelling, so we can use plain strcmp */
2851+
(void) GetConfigOptionByName(name, &varname);
2852+
name = varname;
2853+
28492854
newval = palloc(strlen(name) + 1 + strlen(value) + 1);
28502855
sprintf(newval, "%s=%s", name, value);
28512856
datum = DirectFunctionCall1(textin, CStringGetDatum(newval));
@@ -2909,6 +2914,7 @@ GUCArrayAdd(ArrayType *array, const char *name, const char *value)
29092914
ArrayType *
29102915
GUCArrayDelete(ArrayType *array, const char *name)
29112916
{
2917+
const char *varname;
29122918
ArrayType *newarray;
29132919
int i;
29142920
int index;
@@ -2920,6 +2926,10 @@ GUCArrayDelete(ArrayType *array, const char *name)
29202926
superuser() ? PGC_SUSET : PGC_USERSET,
29212927
PGC_S_SESSION, false, false);
29222928

2929+
/* convert name to canonical spelling, so we can use plain strcmp */
2930+
(void) GetConfigOptionByName(name, &varname);
2931+
name = varname;
2932+
29232933
/* if array is currently null, then surely nothing to delete */
29242934
if (!array)
29252935
return NULL;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy