mirror of
https://github.com/postgres/postgres.git
synced 2025-04-29 13:56:47 +03:00
Fix potential coredump in pg_conndefaults (assigning constant string
to a field that will get free'd). Also make it robust in cases where values contain Tcl special characters.
This commit is contained in:
parent
3f2fff5c5d
commit
820f9f8be8
@ -7,7 +7,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/interfaces/libpgtcl/Attic/pgtclCmds.c,v 1.36 1998/10/01 01:45:38 tgl Exp $
|
* $Header: /cvsroot/pgsql/src/interfaces/libpgtcl/Attic/pgtclCmds.c,v 1.37 1998/10/02 01:37:17 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -240,21 +240,23 @@ int
|
|||||||
Pg_conndefaults(ClientData cData, Tcl_Interp * interp, int argc, char **argv)
|
Pg_conndefaults(ClientData cData, Tcl_Interp * interp, int argc, char **argv)
|
||||||
{
|
{
|
||||||
PQconninfoOption *option;
|
PQconninfoOption *option;
|
||||||
char buf[8192];
|
Tcl_DString result;
|
||||||
|
char ibuf[32];
|
||||||
|
|
||||||
Tcl_ResetResult(interp);
|
Tcl_DStringInit(&result);
|
||||||
for (option = PQconndefaults(); option->keyword != NULL; option++)
|
for (option = PQconndefaults(); option->keyword != NULL; option++)
|
||||||
{
|
{
|
||||||
if (option->val == NULL)
|
char * val = option->val ? option->val : "";
|
||||||
option->val = "";
|
sprintf(ibuf, "%d", option->dispsize);
|
||||||
sprintf(buf, "{%s} {%s} {%s} %d {%s}",
|
Tcl_DStringStartSublist(&result);
|
||||||
option->keyword,
|
Tcl_DStringAppendElement(&result, option->keyword);
|
||||||
option->label,
|
Tcl_DStringAppendElement(&result, option->label);
|
||||||
option->dispchar,
|
Tcl_DStringAppendElement(&result, option->dispchar);
|
||||||
option->dispsize,
|
Tcl_DStringAppendElement(&result, ibuf);
|
||||||
option->val);
|
Tcl_DStringAppendElement(&result, val);
|
||||||
Tcl_AppendElement(interp, buf);
|
Tcl_DStringEndSublist(&result);
|
||||||
}
|
}
|
||||||
|
Tcl_DStringResult(interp, &result);
|
||||||
|
|
||||||
return TCL_OK;
|
return TCL_OK;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user