From 896a42a5a75b6fdd63f94e31f8ea970440d7b785 Mon Sep 17 00:00:00 2001 From: "Marc G. Fournier" Date: Wed, 1 Apr 1998 15:35:33 +0000 Subject: [PATCH] From: Maurice Gittens After applying the following patch there remain two probable buffer overruns detected by Electric Fence during the regression test. I'll try find out what causes the remain two ones. This patch also corrects a typo in smgr.c. --- src/backend/catalog/pg_aggregate.c | 6 ++++-- src/backend/catalog/pg_operator.c | 11 ++++++++--- src/backend/catalog/pg_proc.c | 6 ++++-- src/backend/catalog/pg_type.c | 10 +++++----- src/backend/storage/smgr/smgr.c | 4 ++-- 5 files changed, 23 insertions(+), 14 deletions(-) diff --git a/src/backend/catalog/pg_aggregate.c b/src/backend/catalog/pg_aggregate.c index 84515e70ed..1a650b3d97 100644 --- a/src/backend/catalog/pg_aggregate.c +++ b/src/backend/catalog/pg_aggregate.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/catalog/pg_aggregate.c,v 1.13 1998/02/26 04:30:40 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/catalog/pg_aggregate.c,v 1.14 1998/04/01 15:35:01 scrappy Exp $ * *------------------------------------------------------------------------- */ @@ -78,6 +78,7 @@ AggregateCreate(char *aggName, Oid xret2 = InvalidOid; Oid fret = InvalidOid; Oid fnArgs[8]; + NameData aname; TupleDesc tupDesc; MemSet(fnArgs, 0, 8 * sizeof(Oid)); @@ -202,7 +203,8 @@ AggregateCreate(char *aggName, nulls[i] = ' '; values[i] = (Datum) NULL; } - values[Anum_pg_aggregate_aggname - 1] = PointerGetDatum(aggName); + namestrcpy(&aname, aggName); + values[Anum_pg_aggregate_aggname - 1] = NameGetDatum(&aname); values[Anum_pg_aggregate_aggowner - 1] = Int32GetDatum(GetUserId()); values[Anum_pg_aggregate_aggtransfn1 - 1] = diff --git a/src/backend/catalog/pg_operator.c b/src/backend/catalog/pg_operator.c index fc25127427..1529afabab 100644 --- a/src/backend/catalog/pg_operator.c +++ b/src/backend/catalog/pg_operator.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/catalog/pg_operator.c,v 1.22 1998/02/26 04:30:41 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/catalog/pg_operator.c,v 1.23 1998/04/01 15:35:04 scrappy Exp $ * * NOTES * these routines moved here from commands/define.c and somewhat cleaned up. @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -229,6 +230,7 @@ OperatorShellMakeWithOpenRelation(Relation pg_operator_desc, Datum values[Natts_pg_operator]; char nulls[Natts_pg_operator]; Oid operatorObjectId; + NameData oname; TupleDesc tupDesc; /* ---------------- @@ -246,7 +248,8 @@ OperatorShellMakeWithOpenRelation(Relation pg_operator_desc, * ---------------- */ i = 0; - values[i++] = PointerGetDatum(operatorName); + namestrcpy(&oname, operatorName); + values[i++] = NameGetDatum(&oname); values[i++] = Int32GetDatum(GetUserId()); values[i++] = (Datum) (uint16) 0; @@ -474,6 +477,7 @@ OperatorDef(char *operatorName, char *name[4]; Oid typeId[8]; int nargs; + NameData oname; TupleDesc tupDesc; static ScanKeyData opKey[3] = { @@ -608,7 +612,8 @@ OperatorDef(char *operatorName, * ---------------- */ i = 0; - values[i++] = PointerGetDatum(operatorName); + namestrcpy(&oname, operatorName); + values[i++] = NameGetDatum(&oname); values[i++] = Int32GetDatum(GetUserId()); values[i++] = UInt16GetDatum(precedence); values[i++] = leftTypeName ? (rightTypeName ? 'b' : 'r') : 'l'; diff --git a/src/backend/catalog/pg_proc.c b/src/backend/catalog/pg_proc.c index f300b97965..5eaa5833ab 100644 --- a/src/backend/catalog/pg_proc.c +++ b/src/backend/catalog/pg_proc.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/catalog/pg_proc.c,v 1.15 1998/02/26 04:30:43 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/catalog/pg_proc.c,v 1.16 1998/04/01 15:35:05 scrappy Exp $ * *------------------------------------------------------------------------- */ @@ -71,6 +71,7 @@ ProcedureCreate(char *procedureName, Oid relid; Oid toid; text *prosrctext; + NameData procname; TupleDesc tupDesc; /* ---------------- @@ -229,7 +230,8 @@ ProcedureCreate(char *procedureName, } i = 0; - values[i++] = PointerGetDatum(procedureName); + namestrcpy(&procname, procedureName); + values[i++] = NameGetDatum(&procname); values[i++] = Int32GetDatum(GetUserId()); values[i++] = ObjectIdGetDatum(languageObjectId); diff --git a/src/backend/catalog/pg_type.c b/src/backend/catalog/pg_type.c index 2ca77f2992..d08e44a8ee 100644 --- a/src/backend/catalog/pg_type.c +++ b/src/backend/catalog/pg_type.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/catalog/pg_type.c,v 1.21 1998/03/30 17:46:45 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/catalog/pg_type.c,v 1.22 1998/04/01 15:35:08 scrappy Exp $ * *------------------------------------------------------------------------- */ @@ -160,6 +160,7 @@ TypeShellMakeWithOpenRelation(Relation pg_type_desc, char *typeName) Datum values[Natts_pg_type]; char nulls[Natts_pg_type]; Oid typoid; + NameData name; TupleDesc tupDesc; /* ---------------- @@ -177,7 +178,8 @@ TypeShellMakeWithOpenRelation(Relation pg_type_desc, char *typeName) * ---------------- */ i = 0; - values[i++] = (Datum) typeName; /* 1 */ + namestrcpy(&name, typeName); + values[i++] = NameGetDatum(&name); /* 1 */ values[i++] = (Datum) InvalidOid; /* 2 */ values[i++] = (Datum) (int16) 0; /* 3 */ values[i++] = (Datum) (int16) 0; /* 4 */ @@ -315,11 +317,9 @@ TypeCreate(char *typeName, char *procs[4]; bool defined; ItemPointerData itemPointerData; + NameData name; TupleDesc tupDesc; - Oid argList[8]; - NameData name; - static ScanKeyData typeKey[1] = { {0, Anum_pg_type_typname, NameEqualRegProcedure} diff --git a/src/backend/storage/smgr/smgr.c b/src/backend/storage/smgr/smgr.c index e7f9d2d831..c6956b3099 100644 --- a/src/backend/storage/smgr/smgr.c +++ b/src/backend/storage/smgr/smgr.c @@ -10,7 +10,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/storage/smgr/smgr.c,v 1.13 1998/01/07 21:05:45 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/storage/smgr/smgr.c,v 1.14 1998/04/01 15:35:33 scrappy Exp $ * *------------------------------------------------------------------------- */ @@ -132,7 +132,7 @@ smgrcreate(int16 which, Relation reln) int fd; if ((fd = (*(smgrsw[which].smgr_create)) (reln)) < 0) - elog(ERROR, "cannot open %s", + elog(ERROR, "cannot create %s", &(reln->rd_rel->relname.data[0])); return (fd); -- 2.40.0