I checked all the previous string handling errors and most of them were

already fixed by You. However there were a few left and attached patch
should fix the rest of them.

I used StringInfo only in 2 places and both of them are inside debug
ifdefs. Only performance penalty will come from using strlen() like all
the other code does.

I also modified some of the already patched parts by changing
snprintf(buf, 2 * BUFSIZE, ... style lines to
snprintf(buf, sizeof(buf), ... where buf is an array.

Jukka Holappa
This commit is contained in:
Bruce Momjian 2002-09-02 06:11:43 +00:00
parent 48e1a39924
commit a12b4e279b
16 changed files with 107 additions and 105 deletions

View File

@ -164,8 +164,9 @@ int cube_yyerror ( char *msg ) {
position = parse_buffer_pos() > parse_buffer_size() ? parse_buffer_pos() - 1 : parse_buffer_pos(); position = parse_buffer_pos() > parse_buffer_size() ? parse_buffer_pos() - 1 : parse_buffer_pos();
sprintf( snprintf(
buf, buf,
256,
"%s at or before position %d, character ('%c', \\%03o), input: '%s'\n", "%s at or before position %d, character ('%c', \\%03o), input: '%s'\n",
msg, msg,
position, position,

View File

@ -22,6 +22,7 @@
#include "utils/array.h" #include "utils/array.h"
#include "utils/builtins.h" #include "utils/builtins.h"
#include "storage/bufpage.h" #include "storage/bufpage.h"
#include "lib/stringinfo.h"
/* number ranges for compression */ /* number ranges for compression */
#define MAXNUMRANGE 100 #define MAXNUMRANGE 100
@ -99,20 +100,19 @@ typedef char *BITVECP;
static void static void
printarr(ArrayType *a, int num) printarr(ArrayType *a, int num)
{ {
char bbb[16384]; StringInfoData bbb;
char *cur; char *cur;
int l; int l;
int *d; int *d;
d = ARRPTR(a); d = ARRPTR(a);
*bbb = '\0'; initStringInfo(&bbb);
cur = bbb;
for (l = 0; l < min(num, ARRNELEMS(a)); l++) for (l = 0; l < min(num, ARRNELEMS(a)); l++)
{ {
sprintf(cur, "%d ", d[l]); appendStringInfo(&bbb, "%d ", d[l]);
cur = strchr(cur, '\0');
} }
elog(DEBUG3, "\t\t%s", bbb); elog(DEBUG3, "\t\t%s", bbb.data);
pfree(bbb.data);
} }
static void static void
printbitvec(BITVEC bv) printbitvec(BITVEC bv)
@ -1924,7 +1924,7 @@ bqarr_in(PG_FUNCTION_ARGS) {
NODE *tmp; NODE *tmp;
int4 pos=0; int4 pos=0;
#ifdef BS_DEBUG #ifdef BS_DEBUG
char pbuf[16384],*cur; StringInfoData pbuf;
#endif #endif
state.buf = buf; state.buf = buf;
@ -1955,16 +1955,15 @@ bqarr_in(PG_FUNCTION_ARGS) {
pos = query->size-1; pos = query->size-1;
findoprnd( ptr, &pos ); findoprnd( ptr, &pos );
#ifdef BS_DEBUG #ifdef BS_DEBUG
cur = pbuf; initStringInfo(&pbuf);
*cur = '\0';
for( i=0;i<query->size;i++ ) { for( i=0;i<query->size;i++ ) {
if ( ptr[i].type == OPR ) if ( ptr[i].type == OPR )
sprintf(cur, "%c(%d) ", ptr[i].val, ptr[i].left); appendStringInfo(&pbuf, "%c(%d) ", ptr[i].val, ptr[i].left);
else else
sprintf(cur, "%d ", ptr[i].val ); appendStringInfo(&pbuf, "%d ", ptr[i].val );
cur = strchr(cur,'\0');
} }
elog(DEBUG3,"POR: %s", pbuf); elog(DEBUG3,"POR: %s", pbuf.data);
pfree(pbuf.data);
#endif #endif
PG_RETURN_POINTER( query ); PG_RETURN_POINTER( query );

View File

@ -144,7 +144,7 @@ float seg_atof ( char *value ) {
sscanf(value, "%f", &result); sscanf(value, "%f", &result);
if ( errno ) { if ( errno ) {
sprintf(buf, "numeric value %s unrepresentable", value); snprintf(buf, 256, "numeric value %s unrepresentable", value);
reset_parse_buffer(); reset_parse_buffer();
elog(ERROR, buf); elog(ERROR, buf);
} }
@ -165,8 +165,9 @@ int seg_yyerror ( char *msg ) {
position = parse_buffer_pos() > parse_buffer_size() ? parse_buffer_pos() - 1 : parse_buffer_pos(); position = parse_buffer_pos() > parse_buffer_size() ? parse_buffer_pos() - 1 : parse_buffer_pos();
sprintf( snprintf(
buf, buf,
256,
"%s at or near position %d, character ('%c', \\%03o), input: '%s'\n", "%s at or near position %d, character ('%c', \\%03o), input: '%s'\n",
msg, msg,
position, position,

View File

@ -112,7 +112,7 @@ check_primary_key(PG_FUNCTION_ARGS)
* Construct ident string as TriggerName $ TriggeredRelationId and try * Construct ident string as TriggerName $ TriggeredRelationId and try
* to find prepared execution plan. * to find prepared execution plan.
*/ */
snprintf(ident, 2 * NAMEDATALEN, "%s$%u", trigger->tgname, rel->rd_id); snprintf(ident, sizeof(ident), "%s$%u", trigger->tgname, rel->rd_id);
plan = find_plan(ident, &PPlans, &nPPlans); plan = find_plan(ident, &PPlans, &nPPlans);
/* if there is no plan then allocate argtypes for preparation */ /* if there is no plan then allocate argtypes for preparation */
@ -160,10 +160,10 @@ check_primary_key(PG_FUNCTION_ARGS)
* Construct query: SELECT 1 FROM _referenced_relation_ WHERE * Construct query: SELECT 1 FROM _referenced_relation_ WHERE
* Pkey1 = $1 [AND Pkey2 = $2 [...]] * Pkey1 = $1 [AND Pkey2 = $2 [...]]
*/ */
snprintf(sql, 8192, "select 1 from %s where ", relname); snprintf(sql, sizeof(sql), "select 1 from %s where ", relname);
for (i = 0; i < nkeys; i++) for (i = 0; i < nkeys; i++)
{ {
snprintf(sql + strlen(sql), 8192 - strlen(sql), "%s = $%d %s", snprintf(sql + strlen(sql), sizeof(sql) - strlen(sql), "%s = $%d %s",
args[i + nkeys + 1], i + 1, (i < nkeys - 1) ? "and " : ""); args[i + nkeys + 1], i + 1, (i < nkeys - 1) ? "and " : "");
} }
@ -320,7 +320,7 @@ check_foreign_key(PG_FUNCTION_ARGS)
* Construct ident string as TriggerName $ TriggeredRelationId and try * Construct ident string as TriggerName $ TriggeredRelationId and try
* to find prepared execution plan(s). * to find prepared execution plan(s).
*/ */
snprintf(ident, 2 * NAMEDATALEN, "%s$%u", trigger->tgname, rel->rd_id); snprintf(ident, sizeof(ident), "%s$%u", trigger->tgname, rel->rd_id);
plan = find_plan(ident, &FPlans, &nFPlans); plan = find_plan(ident, &FPlans, &nFPlans);
/* if there is no plan(s) then allocate argtypes for preparation */ /* if there is no plan(s) then allocate argtypes for preparation */
@ -411,7 +411,7 @@ check_foreign_key(PG_FUNCTION_ARGS)
*/ */
if (action == 'r') if (action == 'r')
snprintf(sql, 8192, "select 1 from %s where ", relname); snprintf(sql, sizeof(sql), "select 1 from %s where ", relname);
/*--------- /*---------
* For 'C'ascade action we construct DELETE query * For 'C'ascade action we construct DELETE query
@ -438,7 +438,7 @@ check_foreign_key(PG_FUNCTION_ARGS)
char *nv; char *nv;
int k; int k;
snprintf(sql, 8192, "update %s set ", relname); snprintf(sql, sizeof(sql), "update %s set ", relname);
for (k = 1; k <= nkeys; k++) for (k = 1; k <= nkeys; k++)
{ {
int is_char_type = 0; int is_char_type = 0;
@ -461,7 +461,7 @@ check_foreign_key(PG_FUNCTION_ARGS)
* is_char_type =1 i set ' ' for define a new * is_char_type =1 i set ' ' for define a new
* value * value
*/ */
snprintf(sql + strlen(sql), 8192 - strlen(sql), snprintf(sql + strlen(sql), sizeof(sql) - strlen(sql),
" %s = %s%s%s %s ", " %s = %s%s%s %s ",
args2[k], (is_char_type > 0) ? "'" : "", args2[k], (is_char_type > 0) ? "'" : "",
nv, (is_char_type > 0) ? "'" : "", (k < nkeys) ? ", " : ""); nv, (is_char_type > 0) ? "'" : "", (k < nkeys) ? ", " : "");
@ -472,7 +472,7 @@ check_foreign_key(PG_FUNCTION_ARGS)
} }
else else
/* DELETE */ /* DELETE */
snprintf(sql, 8192, "delete from %s where ", relname); snprintf(sql, sizeof(sql), "delete from %s where ", relname);
} }
@ -484,10 +484,10 @@ check_foreign_key(PG_FUNCTION_ARGS)
*/ */
else if (action == 's') else if (action == 's')
{ {
snprintf(sql, 8192, "update %s set ", relname); snprintf(sql, sizeof(sql), "update %s set ", relname);
for (i = 1; i <= nkeys; i++) for (i = 1; i <= nkeys; i++)
{ {
snprintf(sql + strlen(sql), 8192 - strlen(sql), snprintf(sql + strlen(sql), sizeof(sql) - strlen(sql),
"%s = null%s", "%s = null%s",
args2[i], (i < nkeys) ? ", " : ""); args2[i], (i < nkeys) ? ", " : "");
} }
@ -497,7 +497,7 @@ check_foreign_key(PG_FUNCTION_ARGS)
/* Construct WHERE qual */ /* Construct WHERE qual */
for (i = 1; i <= nkeys; i++) for (i = 1; i <= nkeys; i++)
{ {
snprintf(sql + strlen(sql), 8192 - strlen(sql), "%s = $%d %s", snprintf(sql + strlen(sql), sizeof(sql) - strlen(sql), "%s = $%d %s",
args2[i], i, (i < nkeys) ? "and " : ""); args2[i], i, (i < nkeys) ? "and " : "");
} }
@ -547,7 +547,7 @@ check_foreign_key(PG_FUNCTION_ARGS)
relname = args[0]; relname = args[0];
snprintf(ident, 2 * NAMEDATALEN, "%s$%u", trigger->tgname, rel->rd_id); snprintf(ident, sizeof(ident), "%s$%u", trigger->tgname, rel->rd_id);
plan = find_plan(ident, &FPlans, &nFPlans); plan = find_plan(ident, &FPlans, &nFPlans);
ret = SPI_execp(plan->splan[r], kvals, NULL, tcount); ret = SPI_execp(plan->splan[r], kvals, NULL, tcount);
/* we have no NULLs - so we pass ^^^^ here */ /* we have no NULLs - so we pass ^^^^ here */

View File

@ -250,7 +250,7 @@ timetravel(PG_FUNCTION_ARGS)
* Construct ident string as TriggerName $ TriggeredRelationId and try * Construct ident string as TriggerName $ TriggeredRelationId and try
* to find prepared execution plan. * to find prepared execution plan.
*/ */
snprintf(ident, 2 * NAMEDATALEN, "%s$%u", trigger->tgname, rel->rd_id); snprintf(ident, sizeof(ident), "%s$%u", trigger->tgname, rel->rd_id);
plan = find_plan(ident, &Plans, &nPlans); plan = find_plan(ident, &Plans, &nPlans);
/* if there is no plan ... */ /* if there is no plan ... */
@ -266,10 +266,10 @@ timetravel(PG_FUNCTION_ARGS)
/* /*
* Construct query: INSERT INTO _relation_ VALUES ($1, ...) * Construct query: INSERT INTO _relation_ VALUES ($1, ...)
*/ */
snprintf(sql, 8192, "INSERT INTO %s VALUES (", relname); snprintf(sql, sizeof(sql), "INSERT INTO %s VALUES (", relname);
for (i = 1; i <= natts; i++) for (i = 1; i <= natts; i++)
{ {
snprintf(sql + strlen(sql), 8192 - strlen(sql), "$%d%s", snprintf(sql + strlen(sql), sizeof(sql) - strlen(sql), "$%d%s",
i, (i < natts) ? ", " : ")"); i, (i < natts) ? ", " : ")");
ctypes[i - 1] = SPI_gettypeid(tupdesc, i); ctypes[i - 1] = SPI_gettypeid(tupdesc, i);
} }

View File

@ -1,5 +1,5 @@
<!-- <!--
$Header: /cvsroot/pgsql/doc/src/sgml/spi.sgml,v 1.22 2002/03/22 19:20:30 petere Exp $ $Header: /cvsroot/pgsql/doc/src/sgml/spi.sgml,v 1.23 2002/09/02 06:11:42 momjian Exp $
--> -->
<Chapter id="spi"> <Chapter id="spi">
@ -3815,7 +3815,7 @@ execq(text *sql, int cnt)
HeapTuple tuple = tuptable->vals[j]; HeapTuple tuple = tuptable->vals[j];
for (i = 1, buf[0] = 0; i <= tupdesc->natts; i++) for (i = 1, buf[0] = 0; i <= tupdesc->natts; i++)
sprintf(buf + strlen (buf), " %s%s", snprintf(buf + strlen (buf), sizeof(buf) - strlen(buf)," %s%s",
SPI_getvalue(tuple, tupdesc, i), SPI_getvalue(tuple, tupdesc, i),
(i == tupdesc->natts) ? " " : " |"); (i == tupdesc->natts) ? " " : " |");
elog (INFO, "EXECQ: %s", buf); elog (INFO, "EXECQ: %s", buf);

View File

@ -6,7 +6,7 @@
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $Header: /cvsroot/pgsql/src/backend/parser/analyze.c,v 1.246 2002/08/29 07:22:22 ishii Exp $ * $Header: /cvsroot/pgsql/src/backend/parser/analyze.c,v 1.247 2002/09/02 06:11:42 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -2153,7 +2153,7 @@ transformSetOperationTree(ParseState *pstate, SelectStmt *stmt)
/* /*
* Make the leaf query be a subquery in the top-level rangetable. * Make the leaf query be a subquery in the top-level rangetable.
*/ */
snprintf(selectName, 32, "*SELECT* %d", length(pstate->p_rtable) + 1); snprintf(selectName, sizeof(selectName), "*SELECT* %d", length(pstate->p_rtable) + 1);
rte = addRangeTableEntryForSubquery(pstate, rte = addRangeTableEntryForSubquery(pstate,
selectQuery, selectQuery,
makeAlias(selectName, NIL), makeAlias(selectName, NIL),

View File

@ -7,7 +7,7 @@
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/storage/file/fd.c,v 1.94 2002/09/02 02:47:03 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/storage/file/fd.c,v 1.95 2002/09/02 06:11:42 momjian Exp $
* *
* NOTES: * NOTES:
* *
@ -344,14 +344,14 @@ _dump_lru(void)
Vfd *vfdP = &VfdCache[mru]; Vfd *vfdP = &VfdCache[mru];
char buf[2048]; char buf[2048];
sprintf(buf, "LRU: MOST %d ", mru); snprintf(buf, sizeof(buf), "LRU: MOST %d ", mru);
while (mru != 0) while (mru != 0)
{ {
mru = vfdP->lruLessRecently; mru = vfdP->lruLessRecently;
vfdP = &VfdCache[mru]; vfdP = &VfdCache[mru];
sprintf(buf + strlen(buf), "%d ", mru); snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "%d ", mru);
} }
sprintf(buf + strlen(buf), "LEAST"); snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "LEAST");
elog(LOG, buf); elog(LOG, buf);
} }
#endif /* FDDEBUG */ #endif /* FDDEBUG */

View File

@ -17,7 +17,7 @@
* *
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* *
* $Header: /cvsroot/pgsql/src/backend/utils/adt/ri_triggers.c,v 1.40 2002/07/30 16:33:21 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/utils/adt/ri_triggers.c,v 1.41 2002/09/02 06:11:42 momjian Exp $
* *
* ---------- * ----------
*/ */
@ -262,7 +262,7 @@ RI_FKey_check(PG_FUNCTION_ARGS)
* ---------- * ----------
*/ */
quoteRelationName(pkrelname, pk_rel); quoteRelationName(pkrelname, pk_rel);
sprintf(querystr, "SELECT 1 FROM ONLY %s x FOR UPDATE OF x", snprintf(querystr, sizeof(querystr), "SELECT 1 FROM ONLY %s x FOR UPDATE OF x",
pkrelname); pkrelname);
/* /*
@ -413,13 +413,13 @@ RI_FKey_check(PG_FUNCTION_ARGS)
* ---------- * ----------
*/ */
quoteRelationName(pkrelname, pk_rel); quoteRelationName(pkrelname, pk_rel);
sprintf(querystr, "SELECT 1 FROM ONLY %s x", pkrelname); snprintf(querystr, sizeof(querystr), "SELECT 1 FROM ONLY %s x", pkrelname);
querysep = "WHERE"; querysep = "WHERE";
for (i = 0; i < qkey.nkeypairs; i++) for (i = 0; i < qkey.nkeypairs; i++)
{ {
quoteOneName(attname, quoteOneName(attname,
tgargs[RI_FIRST_ATTNAME_ARGNO + i * 2 + RI_KEYPAIR_PK_IDX]); tgargs[RI_FIRST_ATTNAME_ARGNO + i * 2 + RI_KEYPAIR_PK_IDX]);
sprintf(querystr + strlen(querystr), " %s %s = $%d", snprintf(querystr + strlen(querystr), sizeof(querystr) - strlen(querystr), " %s %s = $%d",
querysep, attname, i+1); querysep, attname, i+1);
querysep = "AND"; querysep = "AND";
queryoids[i] = SPI_gettypeid(fk_rel->rd_att, queryoids[i] = SPI_gettypeid(fk_rel->rd_att,
@ -614,13 +614,13 @@ ri_Check_Pk_Match(Relation pk_rel, HeapTuple old_row, Oid tgoid, int match_type,
* ---------- * ----------
*/ */
quoteRelationName(pkrelname, pk_rel); quoteRelationName(pkrelname, pk_rel);
sprintf(querystr, "SELECT 1 FROM ONLY %s x", pkrelname); snprintf(querystr, sizeof(querystr), "SELECT 1 FROM ONLY %s x", pkrelname);
querysep = "WHERE"; querysep = "WHERE";
for (i = 0; i < qkey.nkeypairs; i++) for (i = 0; i < qkey.nkeypairs; i++)
{ {
quoteOneName(attname, quoteOneName(attname,
tgargs[RI_FIRST_ATTNAME_ARGNO + i * 2 + RI_KEYPAIR_PK_IDX]); tgargs[RI_FIRST_ATTNAME_ARGNO + i * 2 + RI_KEYPAIR_PK_IDX]);
sprintf(querystr + strlen(querystr), " %s %s = $%d", snprintf(querystr + strlen(querystr), sizeof(querystr) - strlen(querystr), " %s %s = $%d",
querysep, attname, i+1); querysep, attname, i+1);
querysep = "AND"; querysep = "AND";
queryoids[i] = SPI_gettypeid(pk_rel->rd_att, queryoids[i] = SPI_gettypeid(pk_rel->rd_att,
@ -816,13 +816,13 @@ RI_FKey_noaction_del(PG_FUNCTION_ARGS)
* ---------- * ----------
*/ */
quoteRelationName(fkrelname, fk_rel); quoteRelationName(fkrelname, fk_rel);
sprintf(querystr, "SELECT 1 FROM ONLY %s x", fkrelname); snprintf(querystr, sizeof(querystr), "SELECT 1 FROM ONLY %s x", fkrelname);
querysep = "WHERE"; querysep = "WHERE";
for (i = 0; i < qkey.nkeypairs; i++) for (i = 0; i < qkey.nkeypairs; i++)
{ {
quoteOneName(attname, quoteOneName(attname,
tgargs[RI_FIRST_ATTNAME_ARGNO + i * 2 + RI_KEYPAIR_FK_IDX]); tgargs[RI_FIRST_ATTNAME_ARGNO + i * 2 + RI_KEYPAIR_FK_IDX]);
sprintf(querystr + strlen(querystr), " %s %s = $%d", snprintf(querystr + strlen(querystr), sizeof(querystr) - strlen(querystr), " %s %s = $%d",
querysep, attname, i+1); querysep, attname, i+1);
querysep = "AND"; querysep = "AND";
queryoids[i] = SPI_gettypeid(pk_rel->rd_att, queryoids[i] = SPI_gettypeid(pk_rel->rd_att,
@ -1050,13 +1050,13 @@ RI_FKey_noaction_upd(PG_FUNCTION_ARGS)
* ---------- * ----------
*/ */
quoteRelationName(fkrelname, fk_rel); quoteRelationName(fkrelname, fk_rel);
sprintf(querystr, "SELECT 1 FROM ONLY %s x", fkrelname); snprintf(querystr, sizeof(querystr), "SELECT 1 FROM ONLY %s x", fkrelname);
querysep = "WHERE"; querysep = "WHERE";
for (i = 0; i < qkey.nkeypairs; i++) for (i = 0; i < qkey.nkeypairs; i++)
{ {
quoteOneName(attname, quoteOneName(attname,
tgargs[RI_FIRST_ATTNAME_ARGNO + i * 2 + RI_KEYPAIR_FK_IDX]); tgargs[RI_FIRST_ATTNAME_ARGNO + i * 2 + RI_KEYPAIR_FK_IDX]);
sprintf(querystr + strlen(querystr), " %s %s = $%d", snprintf(querystr + strlen(querystr), sizeof(querystr) - strlen(querystr), " %s %s = $%d",
querysep, attname, i+1); querysep, attname, i+1);
querysep = "AND"; querysep = "AND";
queryoids[i] = SPI_gettypeid(pk_rel->rd_att, queryoids[i] = SPI_gettypeid(pk_rel->rd_att,
@ -1257,13 +1257,13 @@ RI_FKey_cascade_del(PG_FUNCTION_ARGS)
* ---------- * ----------
*/ */
quoteRelationName(fkrelname, fk_rel); quoteRelationName(fkrelname, fk_rel);
sprintf(querystr, "DELETE FROM ONLY %s", fkrelname); snprintf(querystr, sizeof(querystr), "DELETE FROM ONLY %s", fkrelname);
querysep = "WHERE"; querysep = "WHERE";
for (i = 0; i < qkey.nkeypairs; i++) for (i = 0; i < qkey.nkeypairs; i++)
{ {
quoteOneName(attname, quoteOneName(attname,
tgargs[RI_FIRST_ATTNAME_ARGNO + i * 2 + RI_KEYPAIR_FK_IDX]); tgargs[RI_FIRST_ATTNAME_ARGNO + i * 2 + RI_KEYPAIR_FK_IDX]);
sprintf(querystr + strlen(querystr), " %s %s = $%d", snprintf(querystr + strlen(querystr), sizeof(querystr) - strlen(querystr), " %s %s = $%d",
querysep, attname, i+1); querysep, attname, i+1);
querysep = "AND"; querysep = "AND";
queryoids[i] = SPI_gettypeid(pk_rel->rd_att, queryoids[i] = SPI_gettypeid(pk_rel->rd_att,
@ -1474,7 +1474,7 @@ RI_FKey_cascade_upd(PG_FUNCTION_ARGS)
* ---------- * ----------
*/ */
quoteRelationName(fkrelname, fk_rel); quoteRelationName(fkrelname, fk_rel);
sprintf(querystr, "UPDATE ONLY %s SET", fkrelname); snprintf(querystr, sizeof(querystr), "UPDATE ONLY %s SET", fkrelname);
qualstr[0] = '\0'; qualstr[0] = '\0';
querysep = ""; querysep = "";
qualsep = "WHERE"; qualsep = "WHERE";
@ -1482,9 +1482,9 @@ RI_FKey_cascade_upd(PG_FUNCTION_ARGS)
{ {
quoteOneName(attname, quoteOneName(attname,
tgargs[RI_FIRST_ATTNAME_ARGNO + i * 2 + RI_KEYPAIR_FK_IDX]); tgargs[RI_FIRST_ATTNAME_ARGNO + i * 2 + RI_KEYPAIR_FK_IDX]);
sprintf(querystr + strlen(querystr), "%s %s = $%d", snprintf(querystr + strlen(querystr), sizeof(querystr) - strlen(querystr), "%s %s = $%d",
querysep, attname, i+1); querysep, attname, i+1);
sprintf(qualstr + strlen(qualstr), " %s %s = $%d", snprintf(qualstr + strlen(qualstr), sizeof(qualstr) - strlen(qualstr), " %s %s = $%d",
qualsep, attname, j+1); qualsep, attname, j+1);
querysep = ","; querysep = ",";
qualsep = "AND"; qualsep = "AND";
@ -1698,13 +1698,13 @@ RI_FKey_restrict_del(PG_FUNCTION_ARGS)
* ---------- * ----------
*/ */
quoteRelationName(fkrelname, fk_rel); quoteRelationName(fkrelname, fk_rel);
sprintf(querystr, "SELECT 1 FROM ONLY %s x", fkrelname); snprintf(querystr, sizeof(querystr), "SELECT 1 FROM ONLY %s x", fkrelname);
querysep = "WHERE"; querysep = "WHERE";
for (i = 0; i < qkey.nkeypairs; i++) for (i = 0; i < qkey.nkeypairs; i++)
{ {
quoteOneName(attname, quoteOneName(attname,
tgargs[RI_FIRST_ATTNAME_ARGNO + i * 2 + RI_KEYPAIR_FK_IDX]); tgargs[RI_FIRST_ATTNAME_ARGNO + i * 2 + RI_KEYPAIR_FK_IDX]);
sprintf(querystr + strlen(querystr), " %s %s = $%d", snprintf(querystr + strlen(querystr), sizeof(querystr) - strlen(querystr), " %s %s = $%d",
querysep, attname, i+1); querysep, attname, i+1);
querysep = "AND"; querysep = "AND";
queryoids[i] = SPI_gettypeid(pk_rel->rd_att, queryoids[i] = SPI_gettypeid(pk_rel->rd_att,
@ -1926,13 +1926,13 @@ RI_FKey_restrict_upd(PG_FUNCTION_ARGS)
* ---------- * ----------
*/ */
quoteRelationName(fkrelname, fk_rel); quoteRelationName(fkrelname, fk_rel);
sprintf(querystr, "SELECT 1 FROM ONLY %s x", fkrelname); snprintf(querystr, sizeof(querystr), "SELECT 1 FROM ONLY %s x", fkrelname);
querysep = "WHERE"; querysep = "WHERE";
for (i = 0; i < qkey.nkeypairs; i++) for (i = 0; i < qkey.nkeypairs; i++)
{ {
quoteOneName(attname, quoteOneName(attname,
tgargs[RI_FIRST_ATTNAME_ARGNO + i * 2 + RI_KEYPAIR_FK_IDX]); tgargs[RI_FIRST_ATTNAME_ARGNO + i * 2 + RI_KEYPAIR_FK_IDX]);
sprintf(querystr + strlen(querystr), " %s %s = $%d", snprintf(querystr + strlen(querystr), sizeof(querystr) - strlen(querystr), " %s %s = $%d",
querysep, attname, i+1); querysep, attname, i+1);
querysep = "AND"; querysep = "AND";
queryoids[i] = SPI_gettypeid(pk_rel->rd_att, queryoids[i] = SPI_gettypeid(pk_rel->rd_att,
@ -2140,7 +2140,7 @@ RI_FKey_setnull_del(PG_FUNCTION_ARGS)
* ---------- * ----------
*/ */
quoteRelationName(fkrelname, fk_rel); quoteRelationName(fkrelname, fk_rel);
sprintf(querystr, "UPDATE ONLY %s SET", fkrelname); snprintf(querystr, sizeof(querystr), "UPDATE ONLY %s SET", fkrelname);
qualstr[0] = '\0'; qualstr[0] = '\0';
querysep = ""; querysep = "";
qualsep = "WHERE"; qualsep = "WHERE";
@ -2148,9 +2148,9 @@ RI_FKey_setnull_del(PG_FUNCTION_ARGS)
{ {
quoteOneName(attname, quoteOneName(attname,
tgargs[RI_FIRST_ATTNAME_ARGNO + i * 2 + RI_KEYPAIR_FK_IDX]); tgargs[RI_FIRST_ATTNAME_ARGNO + i * 2 + RI_KEYPAIR_FK_IDX]);
sprintf(querystr + strlen(querystr), "%s %s = NULL", snprintf(querystr + strlen(querystr), sizeof(querystr) - strlen(querystr), "%s %s = NULL",
querysep, attname); querysep, attname);
sprintf(qualstr + strlen(qualstr), " %s %s = $%d", snprintf(qualstr + strlen(qualstr), sizeof(qualstr) - strlen(qualstr), " %s %s = $%d",
qualsep, attname, i+1); qualsep, attname, i+1);
querysep = ","; querysep = ",";
qualsep = "AND"; qualsep = "AND";
@ -2384,7 +2384,7 @@ RI_FKey_setnull_upd(PG_FUNCTION_ARGS)
* ---------- * ----------
*/ */
quoteRelationName(fkrelname, fk_rel); quoteRelationName(fkrelname, fk_rel);
sprintf(querystr, "UPDATE ONLY %s SET", fkrelname); snprintf(querystr, sizeof(querystr), "UPDATE ONLY %s SET", fkrelname);
qualstr[0] = '\0'; qualstr[0] = '\0';
querysep = ""; querysep = "";
qualsep = "WHERE"; qualsep = "WHERE";
@ -2400,11 +2400,11 @@ RI_FKey_setnull_upd(PG_FUNCTION_ARGS)
!ri_OneKeyEqual(pk_rel, i, old_row, new_row, &qkey, !ri_OneKeyEqual(pk_rel, i, old_row, new_row, &qkey,
RI_KEYPAIR_PK_IDX)) RI_KEYPAIR_PK_IDX))
{ {
sprintf(querystr + strlen(querystr), "%s %s = NULL", snprintf(querystr + strlen(querystr), sizeof(querystr) - strlen(querystr), "%s %s = NULL",
querysep, attname); querysep, attname);
querysep = ","; querysep = ",";
} }
sprintf(qualstr + strlen(qualstr), " %s %s = $%d", snprintf(qualstr + strlen(qualstr), sizeof(qualstr) - strlen(qualstr), " %s %s = $%d",
qualsep, attname, i+1); qualsep, attname, i+1);
qualsep = "AND"; qualsep = "AND";
queryoids[i] = SPI_gettypeid(pk_rel->rd_att, queryoids[i] = SPI_gettypeid(pk_rel->rd_att,
@ -2616,7 +2616,7 @@ RI_FKey_setdefault_del(PG_FUNCTION_ARGS)
* ---------- * ----------
*/ */
quoteRelationName(fkrelname, fk_rel); quoteRelationName(fkrelname, fk_rel);
sprintf(querystr, "UPDATE ONLY %s SET", fkrelname); snprintf(querystr, sizeof(querystr), "UPDATE ONLY %s SET", fkrelname);
qualstr[0] = '\0'; qualstr[0] = '\0';
querysep = ""; querysep = "";
qualsep = "WHERE"; qualsep = "WHERE";
@ -2624,9 +2624,9 @@ RI_FKey_setdefault_del(PG_FUNCTION_ARGS)
{ {
quoteOneName(attname, quoteOneName(attname,
tgargs[RI_FIRST_ATTNAME_ARGNO + i * 2 + RI_KEYPAIR_FK_IDX]); tgargs[RI_FIRST_ATTNAME_ARGNO + i * 2 + RI_KEYPAIR_FK_IDX]);
sprintf(querystr + strlen(querystr), "%s %s = NULL", snprintf(querystr + strlen(querystr), sizeof(querystr) - strlen(querystr), "%s %s = NULL",
querysep, attname); querysep, attname);
sprintf(qualstr + strlen(qualstr), " %s %s = $%d", snprintf(qualstr + strlen(qualstr), sizeof(qualstr) - strlen(qualstr), " %s %s = $%d",
qualsep, attname, i+1); qualsep, attname, i+1);
querysep = ","; querysep = ",";
qualsep = "AND"; qualsep = "AND";
@ -2885,7 +2885,7 @@ RI_FKey_setdefault_upd(PG_FUNCTION_ARGS)
* ---------- * ----------
*/ */
quoteRelationName(fkrelname, fk_rel); quoteRelationName(fkrelname, fk_rel);
sprintf(querystr, "UPDATE ONLY %s SET", fkrelname); snprintf(querystr, sizeof(querystr), "UPDATE ONLY %s SET", fkrelname);
qualstr[0] = '\0'; qualstr[0] = '\0';
querysep = ""; querysep = "";
qualsep = "WHERE"; qualsep = "WHERE";
@ -2901,11 +2901,11 @@ RI_FKey_setdefault_upd(PG_FUNCTION_ARGS)
!ri_OneKeyEqual(pk_rel, i, old_row, !ri_OneKeyEqual(pk_rel, i, old_row,
new_row, &qkey, RI_KEYPAIR_PK_IDX)) new_row, &qkey, RI_KEYPAIR_PK_IDX))
{ {
sprintf(querystr + strlen(querystr), "%s %s = NULL", snprintf(querystr + strlen(querystr), sizeof(querystr) - strlen(querystr), "%s %s = NULL",
querysep, attname); querysep, attname);
querysep = ","; querysep = ",";
} }
sprintf(qualstr + strlen(qualstr), " %s %s = $%d", snprintf(qualstr + strlen(qualstr), sizeof(qualstr) - strlen(qualstr), " %s %s = $%d",
qualsep, attname, i+1); qualsep, attname, i+1);
qualsep = "AND"; qualsep = "AND";
queryoids[i] = SPI_gettypeid(pk_rel->rd_att, queryoids[i] = SPI_gettypeid(pk_rel->rd_att,

View File

@ -22,7 +22,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.295 2002/08/29 00:17:05 tgl Exp $ * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.296 2002/09/02 06:11:42 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -5706,7 +5706,7 @@ setMaxOid(Archive *fout)
PQclear(res); PQclear(res);
if (g_verbose) if (g_verbose)
write_msg(NULL, "maximum system oid is %u\n", max_oid); write_msg(NULL, "maximum system oid is %u\n", max_oid);
snprintf(sql, 1024, snprintf(sql, sizeof(sql),
"CREATE TEMPORARY TABLE pgdump_oid (dummy integer);\n" "CREATE TEMPORARY TABLE pgdump_oid (dummy integer);\n"
"COPY pgdump_oid WITH OIDS FROM stdin;\n" "COPY pgdump_oid WITH OIDS FROM stdin;\n"
"%u\t0\n" "%u\t0\n"

View File

@ -3,7 +3,7 @@
* *
* Copyright 2000-2002 by PostgreSQL Global Development Group * Copyright 2000-2002 by PostgreSQL Global Development Group
* *
* $Header: /cvsroot/pgsql/src/bin/psql/command.c,v 1.78 2002/08/14 05:49:22 momjian Exp $ * $Header: /cvsroot/pgsql/src/bin/psql/command.c,v 1.79 2002/09/02 06:11:42 momjian Exp $
*/ */
#include "postgres_fe.h" #include "postgres_fe.h"
#include "command.h" #include "command.h"
@ -1549,7 +1549,7 @@ do_edit(const char *filename_arg, PQExpBuffer query_buf)
#ifndef WIN32 #ifndef WIN32
const char *tmpdirenv = getenv("TMPDIR"); const char *tmpdirenv = getenv("TMPDIR");
sprintf(fnametmp, "%s/psql.edit.%ld.%ld", snprintf(fnametmp, sizeof(fnametmp), "%s/psql.edit.%ld.%ld",
tmpdirenv ? tmpdirenv : "/tmp", tmpdirenv ? tmpdirenv : "/tmp",
(long) geteuid(), (long) getpid()); (long) geteuid(), (long) getpid());
#else #else

View File

@ -12,7 +12,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/pgc.l,v 1.98 2002/07/30 16:33:08 tgl Exp $ * $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/pgc.l,v 1.99 2002/09/02 06:11:42 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -405,7 +405,7 @@ cppline {space}*#(.*\\{space})*.*
mmerror(PARSE_ERROR, ET_ERROR, "zero-length delimited identifier"); mmerror(PARSE_ERROR, ET_ERROR, "zero-length delimited identifier");
if (literallen >= NAMEDATALEN) if (literallen >= NAMEDATALEN)
{ {
sprintf(errortext, "identifier \"%s\" will be truncated to \"%.*s\"", snprintf(errortext, sizeof(errortext), "identifier \"%s\" will be truncated to \"%.*s\"",
literalbuf, NAMEDATALEN-1, literalbuf); literalbuf, NAMEDATALEN-1, literalbuf);
literalbuf[NAMEDATALEN-1] = '\0'; literalbuf[NAMEDATALEN-1] = '\0';
mmerror(PARSE_ERROR, ET_WARNING, errortext); mmerror(PARSE_ERROR, ET_WARNING, errortext);
@ -831,7 +831,7 @@ cppline {space}*#(.*\\{space})*.*
fprintf(stderr, "Error: Path %s/%s is too long in line %d, skipping.\n", ip->path, yytext, yylineno); fprintf(stderr, "Error: Path %s/%s is too long in line %d, skipping.\n", ip->path, yytext, yylineno);
continue; continue;
} }
sprintf (inc_file, "%s/%s", ip->path, yytext); snprintf (inc_file, sizeof(inc_file), "%s/%s", ip->path, yytext);
yyin = fopen( inc_file, "r" ); yyin = fopen( inc_file, "r" );
if (!yyin) if (!yyin)
{ {
@ -844,7 +844,7 @@ cppline {space}*#(.*\\{space})*.*
} }
if (!yyin) if (!yyin)
{ {
sprintf(errortext, "Cannot open include file %s in line %d\n", yytext, yylineno); snprintf(errortext, sizeof(errortext), "Cannot open include file %s in line %d\n", yytext, yylineno);
mmerror(NO_INCLUDE_FILE, ET_FATAL, errortext); mmerror(NO_INCLUDE_FILE, ET_FATAL, errortext);
} }

View File

@ -1,4 +1,4 @@
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/Attic/preproc.y,v 1.195 2002/07/21 11:09:41 meskes Exp $ */ /* $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/Attic/preproc.y,v 1.196 2002/09/02 06:11:43 momjian Exp $ */
/* Copyright comment */ /* Copyright comment */
%{ %{
@ -582,7 +582,7 @@ stmt: AlterDatabaseSetStmt { output_statement($1, 0, connection); }
if (ptr == NULL) if (ptr == NULL)
{ {
sprintf(errortext, "trying to open undeclared cursor %s\n", $1); snprintf(errortext, sizeof(errortext), "trying to open undeclared cursor %s\n", $1);
mmerror(PARSE_ERROR, ET_ERROR, errortext); mmerror(PARSE_ERROR, ET_ERROR, errortext);
} }
@ -1119,7 +1119,7 @@ columnDef: ColId Typename ColQualList opt_collate
{ {
if (strlen($4) > 0) if (strlen($4) > 0)
{ {
sprintf(errortext, "Currently unsupported CREATE TABLE / COLLATE %s will be passed to backend", $4); snprintf(errortext, sizeof(errortext), "Currently unsupported CREATE TABLE / COLLATE %s will be passed to backend", $4);
mmerror(PARSE_ERROR, ET_WARNING, errortext); mmerror(PARSE_ERROR, ET_WARNING, errortext);
} }
$$ = cat_str(4, $1, $2, $3, $4); $$ = cat_str(4, $1, $2, $3, $4);
@ -2406,7 +2406,7 @@ CursorStmt: DECLARE name opt_cursor CURSOR FOR SelectStmt
if (strcmp($2, ptr->name) == 0) if (strcmp($2, ptr->name) == 0)
{ {
/* re-definition is a bug */ /* re-definition is a bug */
sprintf(errortext, "cursor %s already defined", $2); snprintf(errortext, sizeof(errortext), "cursor %s already defined", $2);
mmerror(PARSE_ERROR, ET_ERROR, errortext); mmerror(PARSE_ERROR, ET_ERROR, errortext);
} }
} }
@ -3628,7 +3628,7 @@ connection_target: database_name opt_server opt_port
/* old style: dbname[@server][:port] */ /* old style: dbname[@server][:port] */
if (strlen($2) > 0 && *($2) != '@') if (strlen($2) > 0 && *($2) != '@')
{ {
sprintf(errortext, "Expected '@', found '%s'", $2); sprintf(errortext, sizeof(errortext), "Expected '@', found '%s'", $2);
mmerror(PARSE_ERROR, ET_ERROR, errortext); mmerror(PARSE_ERROR, ET_ERROR, errortext);
} }
@ -3639,13 +3639,13 @@ connection_target: database_name opt_server opt_port
/* new style: <tcp|unix>:postgresql://server[:port][/dbname] */ /* new style: <tcp|unix>:postgresql://server[:port][/dbname] */
if (strncmp($1, "unix:postgresql", strlen("unix:postgresql")) != 0 && strncmp($1, "tcp:postgresql", strlen("tcp:postgresql")) != 0) if (strncmp($1, "unix:postgresql", strlen("unix:postgresql")) != 0 && strncmp($1, "tcp:postgresql", strlen("tcp:postgresql")) != 0)
{ {
sprintf(errortext, "only protocols 'tcp' and 'unix' and database type 'postgresql' are supported"); snprintf(errortext, sizeof(errortext), "only protocols 'tcp' and 'unix' and database type 'postgresql' are supported");
mmerror(PARSE_ERROR, ET_ERROR, errortext); mmerror(PARSE_ERROR, ET_ERROR, errortext);
} }
if (strncmp($3, "//", strlen("//")) != 0) if (strncmp($3, "//", strlen("//")) != 0)
{ {
sprintf(errortext, "Expected '://', found '%s'", $3); snprintf(errortext, sizeof(errortext), "Expected '://', found '%s'", $3);
mmerror(PARSE_ERROR, ET_ERROR, errortext); mmerror(PARSE_ERROR, ET_ERROR, errortext);
} }
@ -3653,7 +3653,7 @@ connection_target: database_name opt_server opt_port
strncmp($3 + strlen("//"), "localhost", strlen("localhost")) != 0 && strncmp($3 + strlen("//"), "localhost", strlen("localhost")) != 0 &&
strncmp($3 + strlen("//"), "127.0.0.1", strlen("127.0.0.1")) != 0) strncmp($3 + strlen("//"), "127.0.0.1", strlen("127.0.0.1")) != 0)
{ {
sprintf(errortext, "unix domain sockets only work on 'localhost' but not on '%9.9s'", $3 + strlen("//")); snprintf(errortext, sizeof(errortext), "unix domain sockets only work on 'localhost' but not on '%9.9s'", $3 + strlen("//"));
mmerror(PARSE_ERROR, ET_ERROR, errortext); mmerror(PARSE_ERROR, ET_ERROR, errortext);
} }
@ -3686,13 +3686,13 @@ db_prefix: ident CVARIABLE
{ {
if (strcmp($2, "postgresql") != 0 && strcmp($2, "postgres") != 0) if (strcmp($2, "postgresql") != 0 && strcmp($2, "postgres") != 0)
{ {
sprintf(errortext, "Expected 'postgresql', found '%s'", $2); snprintf(errortext, sizeof(errortext), "Expected 'postgresql', found '%s'", $2);
mmerror(PARSE_ERROR, ET_ERROR, errortext); mmerror(PARSE_ERROR, ET_ERROR, errortext);
} }
if (strcmp($1, "tcp") != 0 && strcmp($1, "unix") != 0) if (strcmp($1, "tcp") != 0 && strcmp($1, "unix") != 0)
{ {
sprintf(errortext, "Illegal connection type %s", $1); snprintf(errortext, sizeof(errortext), "Illegal connection type %s", $1);
mmerror(PARSE_ERROR, ET_ERROR, errortext); mmerror(PARSE_ERROR, ET_ERROR, errortext);
} }
@ -3704,7 +3704,7 @@ server: Op server_name
{ {
if (strcmp($1, "@") != 0 && strcmp($1, "//") != 0) if (strcmp($1, "@") != 0 && strcmp($1, "//") != 0)
{ {
sprintf(errortext, "Expected '@' or '://', found '%s'", $1); snprintf(errortext, sizeof(errortext), "Expected '@' or '://', found '%s'", $1);
mmerror(PARSE_ERROR, ET_ERROR, errortext); mmerror(PARSE_ERROR, ET_ERROR, errortext);
} }
@ -3806,7 +3806,7 @@ opt_options: Op ColId
if (strcmp($1, "?") != 0) if (strcmp($1, "?") != 0)
{ {
sprintf(errortext, "unrecognised token '%s'", $1); snprintf(errortext, sizeof(errortext), "unrecognised token '%s'", $1);
mmerror(PARSE_ERROR, ET_ERROR, errortext); mmerror(PARSE_ERROR, ET_ERROR, errortext);
} }
@ -3829,7 +3829,7 @@ ECPGCursorStmt: DECLARE name opt_cursor CURSOR FOR ident
if (strcmp($2, ptr->name) == 0) if (strcmp($2, ptr->name) == 0)
{ {
/* re-definition is a bug */ /* re-definition is a bug */
sprintf(errortext, "cursor %s already defined", $2); snprintf(errortext, sizeof(errortext), "cursor %s already defined", $2);
mmerror(PARSE_ERROR, ET_ERROR, errortext); mmerror(PARSE_ERROR, ET_ERROR, errortext);
} }
} }
@ -3923,7 +3923,7 @@ type_declaration: S_TYPEDEF
if (strcmp($5, ptr->name) == 0) if (strcmp($5, ptr->name) == 0)
{ {
/* re-definition is a bug */ /* re-definition is a bug */
sprintf(errortext, "Type %s already defined", $5); snprintf(errortext, sizeof(errortext), "Type %s already defined", $5);
mmerror(PARSE_ERROR, ET_ERROR, errortext); mmerror(PARSE_ERROR, ET_ERROR, errortext);
} }
} }
@ -4528,7 +4528,7 @@ ECPGTypedef: TYPE_P
if (strcmp($3, ptr->name) == 0) if (strcmp($3, ptr->name) == 0)
{ {
/* re-definition is a bug */ /* re-definition is a bug */
sprintf(errortext, "Type %s already defined", $3); snprintf(errortext, sizeof(errortext), "Type %s already defined", $3);
mmerror(PARSE_ERROR, ET_ERROR, errortext); mmerror(PARSE_ERROR, ET_ERROR, errortext);
} }
} }

View File

@ -80,13 +80,13 @@ find_struct(char *name, char *next)
{ {
if (p->type->type != ECPGt_array) if (p->type->type != ECPGt_array)
{ {
sprintf(errortext, "variable %s is not a pointer", name); snprintf(errortext, sizeof(errortext), "variable %s is not a pointer", name);
mmerror(PARSE_ERROR, ET_FATAL, errortext); mmerror(PARSE_ERROR, ET_FATAL, errortext);
} }
if (p->type->u.element->type != ECPGt_struct && p->type->u.element->type != ECPGt_union) if (p->type->u.element->type != ECPGt_struct && p->type->u.element->type != ECPGt_union)
{ {
sprintf(errortext, "variable %s is not a pointer to a structure or a union", name); snprintf(errortext, sizeof(errortext), "variable %s is not a pointer to a structure or a union", name);
mmerror(PARSE_ERROR, ET_FATAL, errortext); mmerror(PARSE_ERROR, ET_FATAL, errortext);
} }
@ -100,7 +100,7 @@ find_struct(char *name, char *next)
{ {
if (p->type->type != ECPGt_struct && p->type->type != ECPGt_union) if (p->type->type != ECPGt_struct && p->type->type != ECPGt_union)
{ {
sprintf(errortext, "variable %s is neither a structure nor a union", name); snprintf(errortext, sizeof(errortext), "variable %s is neither a structure nor a union", name);
mmerror(PARSE_ERROR, ET_FATAL, errortext); mmerror(PARSE_ERROR, ET_FATAL, errortext);
} }
@ -142,7 +142,7 @@ find_variable(char *name)
if (p == NULL) if (p == NULL)
{ {
sprintf(errortext, "The variable %s is not declared", name); snprintf(errortext, sizeof(errortext), "The variable %s is not declared", name);
mmerror(PARSE_ERROR, ET_FATAL, errortext); mmerror(PARSE_ERROR, ET_FATAL, errortext);
} }
@ -290,7 +290,7 @@ get_typedef(char *name)
for (this = types; this && strcmp(this->name, name); this = this->next); for (this = types; this && strcmp(this->name, name); this = this->next);
if (!this) if (!this)
{ {
sprintf(errortext, "invalid datatype '%s'", name); snprintf(errortext, sizeof(errortext), "invalid datatype '%s'", name);
mmerror(PARSE_ERROR, ET_FATAL, errortext); mmerror(PARSE_ERROR, ET_FATAL, errortext);
} }
@ -320,7 +320,7 @@ adjust_array(enum ECPGttype type_enum, int *dimension, int *length, int type_dim
} }
if (pointer_len>2) if (pointer_len>2)
{ sprintf(errortext, "No multilevel (more than 2) pointer supported %d",pointer_len); { snprintf(errortext, sizeof(errortext), "No multilevel (more than 2) pointer supported %d",pointer_len);
mmerror(PARSE_ERROR, ET_FATAL, errortext); mmerror(PARSE_ERROR, ET_FATAL, errortext);
/* mmerror(PARSE_ERROR, ET_FATAL, "No multilevel (more than 2) pointer supported %d",pointer_len);*/ /* mmerror(PARSE_ERROR, ET_FATAL, "No multilevel (more than 2) pointer supported %d",pointer_len);*/
} }

View File

@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/interfaces/libpgtcl/Attic/pgtclCmds.c,v 1.64 2002/08/18 01:39:43 momjian Exp $ * $Header: /cvsroot/pgsql/src/interfaces/libpgtcl/Attic/pgtclCmds.c,v 1.65 2002/09/02 06:11:43 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -1579,7 +1579,8 @@ Pg_lo_import(ClientData cData, Tcl_Interp *interp, int argc, char *argv[])
lobjId = lo_import(conn, filename); lobjId = lo_import(conn, filename);
if (lobjId == InvalidOid) if (lobjId == InvalidOid)
{ {
sprintf(interp->result, "Pg_lo_import of '%s' failed", filename); /* What is the maximum size of this? FIXME if this is not a good quess */
snprintf(interp->result, 128, "Pg_lo_import of '%s' failed", filename);
return TCL_ERROR; return TCL_ERROR;
} }
sprintf(interp->result, "%u", lobjId); sprintf(interp->result, "%u", lobjId);

View File

@ -10,7 +10,7 @@
* exceed INITIAL_EXPBUFFER_SIZE (currently 256 bytes). * exceed INITIAL_EXPBUFFER_SIZE (currently 256 bytes).
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-auth.c,v 1.69 2002/08/29 03:22:01 tgl Exp $ * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-auth.c,v 1.70 2002/09/02 06:11:43 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -142,7 +142,7 @@ pg_krb4_init()
{ {
char tktbuf[MAXPGPATH]; char tktbuf[MAXPGPATH];
(void) sprintf(tktbuf, "%s@%s", tkt_string(), realm); (void) snprintf(tktbuf, sizeof(tktbuf), "%s@%s", tkt_string(), realm);
krb_set_tkt_string(tktbuf); krb_set_tkt_string(tktbuf);
} }
} }
@ -618,13 +618,13 @@ fe_sendauth(AuthRequest areq, PGconn *conn, const char *hostname,
case AUTH_REQ_PASSWORD: case AUTH_REQ_PASSWORD:
if (password == NULL || *password == '\0') if (password == NULL || *password == '\0')
{ {
(void) sprintf(PQerrormsg, (void) snprintf(PQerrormsg, PQERRORMSG_LENGTH,
"fe_sendauth: no password supplied\n"); "fe_sendauth: no password supplied\n");
return STATUS_ERROR; return STATUS_ERROR;
} }
if (pg_password_sendauth(conn, password, areq) != STATUS_OK) if (pg_password_sendauth(conn, password, areq) != STATUS_OK)
{ {
(void) sprintf(PQerrormsg, (void) snprintf(PQerrormsg, PQERRORMSG_LENGTH,
"fe_sendauth: error sending password authentication\n"); "fe_sendauth: error sending password authentication\n");
return STATUS_ERROR; return STATUS_ERROR;
} }