Hi,
Here's a silly patch, which does the following:
* One unnecessary sprintf becomes strcpy.
* unsigned long is 64 bit on alpha. Extra
paranoia.
* Minor optimisation to strdup.
Matthew.
diff -ruN postgresql-7.1beta5-clean/src/backend/access/transam/xid.c
postgresql-7.1beta5/src/backend/access/transam/xid.c
--- postgresql-7.1beta5-clean/src/backend/access/transam/xid.c Mon Jan 29 02:53:36 2001
+++ postgresql-7.1beta5/src/backend/access/transam/xid.c Sat Feb 24 15:16:36 2001
@@ -49,10 +49,10 @@
xidout(PG_FUNCTION_ARGS)
{
TransactionId transactionId = PG_GETARG_TRANSACTIONID(0);
- /* maximum 32 bit unsigned integer representation takes 10 chars */
- char *representation = palloc(11);
+ /* maximum 64 bit unsigned long representation takes 20 chars */
+ char *representation = palloc(21);
- snprintf(representation, 11, "%lu", (unsigned long) transactionId);
+ snprintf(representation, 21, "%lu", (unsigned long) transactionId);
PG_RETURN_CSTRING(representation);
}
diff -ruN postgresql-7.1beta5-clean/src/backend/access/transam/xlogutils.c
postgresql-7.1beta5/src/backend/access/transam/xlogutils.c
--- postgresql-7.1beta5-clean/src/backend/access/transam/xlogutils.c Fri Feb 23 18:12:00 2001
+++ postgresql-7.1beta5/src/backend/access/transam/xlogutils.c Sat Feb 24 15:16:36 2001
@@ -166,7 +166,7 @@
logRelation->rd_rel = (Form_pg_class) malloc(sizeof(FormData_pg_class));
memset(logRelation->rd_rel, 0, sizeof(FormData_pg_class));
- sprintf(RelationGetPhysicalRelationName(logRelation), "pg_log");
+ strcpy(RelationGetPhysicalRelationName(logRelation), "pg_log");
logRelation->rd_node.tblNode = InvalidOid;
logRelation->rd_node.relNode = RelOid_pg_log;
logRelation->rd_fd = -1;
diff -ruN postgresql-7.1beta5-clean/src/utils/strdup.c postgresql-7.1beta5/src/utils/strdup.c
--- postgresql-7.1beta5-clean/src/utils/strdup.c Mon Jan 29 02:53:58 2001
+++ postgresql-7.1beta5/src/utils/strdup.c Sat Feb 24 15:16:36 2001
@@ -20,7 +20,11 @@
strdup(char const * string)
{
char *nstr;
+ size_t len;
- nstr = strcpy((char *) malloc(strlen(string) + 1), string);
+ len = strlen(string) + 1;
+ nstr = malloc(len);
+ if (nstr)
+ memcpy(nstr, string, len);
return nstr;
}