mirror of
https://github.com/postgres/postgres.git
synced 2025-04-27 22:56:53 +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
|
||||
* $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)
|
||||
{
|
||||
PQconninfoOption *option;
|
||||
char buf[8192];
|
||||
Tcl_DString result;
|
||||
char ibuf[32];
|
||||
|
||||
Tcl_ResetResult(interp);
|
||||
Tcl_DStringInit(&result);
|
||||
for (option = PQconndefaults(); option->keyword != NULL; option++)
|
||||
{
|
||||
if (option->val == NULL)
|
||||
option->val = "";
|
||||
sprintf(buf, "{%s} {%s} {%s} %d {%s}",
|
||||
option->keyword,
|
||||
option->label,
|
||||
option->dispchar,
|
||||
option->dispsize,
|
||||
option->val);
|
||||
Tcl_AppendElement(interp, buf);
|
||||
char * val = option->val ? option->val : "";
|
||||
sprintf(ibuf, "%d", option->dispsize);
|
||||
Tcl_DStringStartSublist(&result);
|
||||
Tcl_DStringAppendElement(&result, option->keyword);
|
||||
Tcl_DStringAppendElement(&result, option->label);
|
||||
Tcl_DStringAppendElement(&result, option->dispchar);
|
||||
Tcl_DStringAppendElement(&result, ibuf);
|
||||
Tcl_DStringAppendElement(&result, val);
|
||||
Tcl_DStringEndSublist(&result);
|
||||
}
|
||||
Tcl_DStringResult(interp, &result);
|
||||
|
||||
return TCL_OK;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user