Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit820f9f8

Browse files
committed
Fix potential coredump in pg_conndefaults (assigning constant string
to a field that will get free'd). Also make it robust in cases wherevalues contain Tcl special characters.
1 parent3f2fff5 commit820f9f8

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed

‎src/interfaces/libpgtcl/pgtclCmds.c

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/interfaces/libpgtcl/Attic/pgtclCmds.c,v 1.36 1998/10/01 01:45:38 tgl Exp $
10+
* $Header: /cvsroot/pgsql/src/interfaces/libpgtcl/Attic/pgtclCmds.c,v 1.37 1998/10/02 01:37:17 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -240,21 +240,23 @@ int
240240
Pg_conndefaults(ClientDatacData,Tcl_Interp*interp,intargc,char**argv)
241241
{
242242
PQconninfoOption*option;
243-
charbuf[8192];
243+
Tcl_DStringresult;
244+
charibuf[32];
244245

245-
Tcl_ResetResult(interp);
246+
Tcl_DStringInit(&result);
246247
for (option=PQconndefaults();option->keyword!=NULL;option++)
247248
{
248-
if (option->val==NULL)
249-
option->val="";
250-
sprintf(buf,"{%s} {%s} {%s} %d {%s}",
251-
option->keyword,
252-
option->label,
253-
option->dispchar,
254-
option->dispsize,
255-
option->val);
256-
Tcl_AppendElement(interp,buf);
257-
}
249+
char*val=option->val ?option->val :"";
250+
sprintf(ibuf,"%d",option->dispsize);
251+
Tcl_DStringStartSublist(&result);
252+
Tcl_DStringAppendElement(&result,option->keyword);
253+
Tcl_DStringAppendElement(&result,option->label);
254+
Tcl_DStringAppendElement(&result,option->dispchar);
255+
Tcl_DStringAppendElement(&result,ibuf);
256+
Tcl_DStringAppendElement(&result,val);
257+
Tcl_DStringEndSublist(&result);
258+
}
259+
Tcl_DStringResult(interp,&result);
258260

259261
returnTCL_OK;
260262
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp