Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 89b762e

Browse files
committed
Fix snprintf with strings, and nextval('"Aa"');
1 parent 434762b commit 89b762e

File tree

7 files changed

+5901
-5898
lines changed

7 files changed

+5901
-5898
lines changed

src/backend/commands/_deadcode/recipe.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/commands/_deadcode/Attic/recipe.c,v 1.1 1999/02/24 17:29:00 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/commands/_deadcode/Attic/recipe.c,v 1.2 1999/03/16 04:25:46 momjian Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -878,8 +878,8 @@ tg_parseSubQuery(TgRecipe * r, TgNode * n, TeeInfo * teeInfo)
878878

879879
snprintf(newquery, 1000, "select %s($1", funcName);
880880
for (i = 1; i < parameterCount; i++)
881-
snprintf(newquery, 1000, "%s,$%d", newquery, i);
882-
snprintf(newquery, 1000, "%s)", newquery);
881+
snprintf(newquery, 1000, "%s,$%d", pstrdup(newquery), i);
882+
snprintf(newquery, 1000, "%s)", pstrdup(newquery));
883883
}
884884
else
885885
snprintf(newquery, 1000, "select %s()", funcName);

src/backend/commands/dbcommands.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/commands/dbcommands.c,v 1.32 1999/03/16 03:24:16 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/commands/dbcommands.c,v 1.33 1999/03/16 04:25:45 momjian Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -85,7 +85,8 @@ createdb(char *dbname, char *dbpath, int encoding, CommandDest dest)
8585

8686
snprintf(buf, 512,
8787
"insert into pg_database (datname, datdba, encoding, datpath)"
88-
" values ('%s', '%d', '%d', '%s');", dbname, user_id, encoding, loc);
88+
" values ('%s', '%d', '%d', '%s');", dbname, user_id, encoding,
89+
loc);
8990

9091
pg_exec_query_dest(buf, dest, false);
9192
}

src/backend/commands/user.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*
66
* Copyright (c) 1994, Regents of the University of California
77
*
8-
* $Id: user.c,v 1.25 1999/03/16 03:24:16 momjian Exp $
8+
* $Id: user.c,v 1.26 1999/03/16 04:25:45 momjian Exp $
99
*
1010
*-------------------------------------------------------------------------
1111
*/
@@ -256,31 +256,33 @@ AlterUser(AlterUserStmt *stmt, CommandDest dest)
256256

257257
if (stmt->password)
258258
{
259-
snprintf(sql, SQL_LENGTH, "%s passwd = '%s'", sql, stmt->password);
259+
snprintf(sql, SQL_LENGTH, "%s passwd = '%s'", pstrdup(sql), stmt->password);
260260
}
261261

262262
if (stmt->createdb)
263263
{
264264
snprintf(sql, SQL_LENGTH, "%s %susecreatedb='%s'",
265-
sql, stmt->password ? "," : "", *stmt->createdb ? "t" : "f");
265+
pstrdup(sql), stmt->password ? "," : "",
266+
*stmt->createdb ? "t" : "f");
266267
}
267268

268269
if (stmt->createuser)
269270
{
270271
snprintf(sql, SQL_LENGTH, "%s %susesuper='%s'",
271-
sql, (stmt->password || stmt->createdb) ? "," : "",
272+
pstrdup(sql), (stmt->password || stmt->createdb) ? "," : "",
272273
*stmt->createuser ? "t" : "f");
273274
}
274275

275276
if (stmt->validUntil)
276277
{
277278
snprintf(sql, SQL_LENGTH, "%s %svaluntil='%s'",
278-
sql,
279+
pstrdup(sql),
279280
(stmt->password || stmt->createdb || stmt->createuser) ? "," : "",
280281
stmt->validUntil);
281282
}
282283

283-
snprintf(sql, SQL_LENGTH, "%s where usename = '%s'", sql, stmt->user);
284+
snprintf(sql, SQL_LENGTH, "%s where usename = '%s'",
285+
pstrdup(sql), stmt->user);
284286

285287
pg_exec_query_dest(sql, dest, false);
286288

0 commit comments

Comments
 (0)