diff options
author | Bruce Momjian | 1998-12-13 04:39:00 +0000 |
---|---|---|
committer | Bruce Momjian | 1998-12-13 04:39:00 +0000 |
commit | 47cae78f7e0bb460f4cda0d526da968a2a94ec55 (patch) | |
tree | 0c96d72e103e58f93b4d9f36e916e91264af1372 | |
parent | bc27c2e4ce922101aa7e05cea39559950f1c7511 (diff) |
While investigating a user's complaint, I have found some memory
destructions in 6.4 source using purify.
(1) parser/gram.y:fmtId()
It writes n+3 bytes into n+1 byte-long memory area if mixed case or
non-ascii identifiers given.
(2) catalog/index.c:
ATTRIBUTE_TUPLE_SIZE bytes are allocated but
sizeof(FormData_pg_attribute) bytes are written. Note that
ATTRIBUTE_TUPLE_SIZE is smaller than
sizeof(FormData_pg_attribute). (for example, on solaris 2.6,
Tatsuo Ishii
-rw-r--r-- | src/backend/catalog/index.c | 6 | ||||
-rw-r--r-- | src/backend/parser/gram.y | 4 |
2 files changed, 5 insertions, 5 deletions
diff --git a/src/backend/catalog/index.c b/src/backend/catalog/index.c index ce48422687b..57d9da12e91 100644 --- a/src/backend/catalog/index.c +++ b/src/backend/catalog/index.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/catalog/index.c,v 1.63 1998/09/10 15:32:16 vadim Exp $ + * $Header: /cvsroot/pgsql/src/backend/catalog/index.c,v 1.63.2.1 1998/12/13 04:39:00 momjian Exp $ * * * INTERFACE ROUTINES @@ -649,7 +649,7 @@ AppendAttributeTuples(Relation indexRelation, int numatts) value[Anum_pg_attribute_attcacheoff - 1] = Int32GetDatum(-1); init_tuple = heap_addheader(Natts_pg_attribute, - sizeof *(indexRelation->rd_att->attrs[0]), + ATTRIBUTE_TUPLE_SIZE, (char *) (indexRelation->rd_att->attrs[0])); hasind = false; @@ -689,7 +689,7 @@ AppendAttributeTuples(Relation indexRelation, int numatts) */ memmove(GETSTRUCT(cur_tuple), (char *) indexTupDesc->attrs[i], - sizeof(FormData_pg_attribute)); + ATTRIBUTE_TUPLE_SIZE); value[Anum_pg_attribute_attnum - 1] = Int16GetDatum(i + 1); diff --git a/src/backend/parser/gram.y b/src/backend/parser/gram.y index d2e34484dac..cdcf7e25965 100644 --- a/src/backend/parser/gram.y +++ b/src/backend/parser/gram.y @@ -10,7 +10,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.37 1998/10/14 15:56:43 thomas Exp $ + * $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.37.2.1 1998/12/13 04:39:00 momjian Exp $ * * HISTORY * AUTHOR DATE MAJOR EVENT @@ -5125,7 +5125,7 @@ fmtId(char *rawid) if (! (islower(*cp) || isdigit(*cp) || (*cp == '_'))) break; if (*cp != '\0') { - cp = palloc(strlen(rawid)+1); + cp = palloc(strlen(rawid)+3); strcpy(cp,"\""); strcat(cp,rawid); strcat(cp,"\""); |