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

Commit 31d825b

Browse files
committed
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
1 parent 589f5aa commit 31d825b

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/backend/catalog/index.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/catalog/index.c,v 1.64 1998/11/27 19:51:49 vadim Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/catalog/index.c,v 1.65 1998/12/13 04:37:50 momjian Exp $
1111
*
1212
*
1313
* INTERFACE ROUTINES
@@ -649,7 +649,7 @@ AppendAttributeTuples(Relation indexRelation, int numatts)
649649
value[Anum_pg_attribute_attcacheoff - 1] = Int32GetDatum(-1);
650650

651651
init_tuple = heap_addheader(Natts_pg_attribute,
652-
sizeof *(indexRelation->rd_att->attrs[0]),
652+
ATTRIBUTE_TUPLE_SIZE,
653653
(char *) (indexRelation->rd_att->attrs[0]));
654654

655655
hasind = false;
@@ -689,7 +689,7 @@ AppendAttributeTuples(Relation indexRelation, int numatts)
689689
*/
690690
memmove(GETSTRUCT(cur_tuple),
691691
(char *) indexTupDesc->attrs[i],
692-
sizeof(FormData_pg_attribute));
692+
ATTRIBUTE_TUPLE_SIZE);
693693

694694
value[Anum_pg_attribute_attnum - 1] = Int16GetDatum(i + 1);
695695

src/backend/parser/gram.y

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
*
1111
*
1212
* IDENTIFICATION
13-
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.38 1998/12/04 15:34:29 thomas Exp $
13+
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.39 1998/12/13 04:37:51 momjian Exp $
1414
*
1515
* HISTORY
1616
* AUTHOR DATE MAJOR EVENT
@@ -5224,7 +5224,7 @@ fmtId(char *rawid)
52245224
if (! (islower(*cp) || isdigit(*cp) || (*cp == '_'))) break;
52255225

52265226
if (*cp != '\0') {
5227-
cp = palloc(strlen(rawid)+1);
5227+
cp = palloc(strlen(rawid)+3);
52285228
strcpy(cp,"\"");
52295229
strcat(cp,rawid);
52305230
strcat(cp,"\"");

0 commit comments

Comments
 (0)