mirror of
https://github.com/postgres/postgres.git
synced 2025-11-10 17:42:29 +03:00
backend where a statically sized buffer is written to. Most of these
should be pretty safe in practice, but it's probably better to be safe than sorry. I was actually looking for cases where NAMEDATALEN is assumed to be 32, but only found one. That's fixed too, as well as a few bits of code cleanup. Neil Conway
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* PostgreSQL type definitions for MAC addresses.
|
||||
*
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/mac.c,v 1.24 2002/06/17 07:00:26 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/mac.c,v 1.25 2002/08/28 20:46:24 momjian Exp $
|
||||
*/
|
||||
|
||||
#include "postgres.h"
|
||||
@@ -80,7 +80,7 @@ macaddr_out(PG_FUNCTION_ARGS)
|
||||
|
||||
result = (char *) palloc(32);
|
||||
|
||||
sprintf(result, "%02x:%02x:%02x:%02x:%02x:%02x",
|
||||
snprintf(result, 32, "%02x:%02x:%02x:%02x:%02x:%02x",
|
||||
addr->a, addr->b, addr->c, addr->d, addr->e, addr->f);
|
||||
|
||||
PG_RETURN_CSTRING(result);
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/tid.c,v 1.33 2002/08/15 16:36:05 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/tid.c,v 1.34 2002/08/28 20:46:24 momjian Exp $
|
||||
*
|
||||
* NOTES
|
||||
* input routine largely stolen from boxin().
|
||||
@@ -101,7 +101,7 @@ tidout(PG_FUNCTION_ARGS)
|
||||
blockNumber = BlockIdGetBlockNumber(blockId);
|
||||
offsetNumber = itemPtr->ip_posid;
|
||||
|
||||
sprintf(buf, "(%u,%u)", blockNumber, offsetNumber);
|
||||
snprintf(buf, sizeof(buf), "(%u,%u)", blockNumber, offsetNumber);
|
||||
|
||||
PG_RETURN_CSTRING(pstrdup(buf));
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/varlena.c,v 1.88 2002/08/22 03:24:00 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/varlena.c,v 1.89 2002/08/28 20:46:24 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -1787,12 +1787,11 @@ to_hex32(PG_FUNCTION_ARGS)
|
||||
{
|
||||
static char digits[] = "0123456789abcdef";
|
||||
char buf[32]; /* bigger than needed, but reasonable */
|
||||
char *ptr,
|
||||
*end;
|
||||
char *ptr;
|
||||
text *result_text;
|
||||
int32 value = PG_GETARG_INT32(0);
|
||||
|
||||
end = ptr = buf + sizeof(buf) - 1;
|
||||
ptr = buf + sizeof(buf) - 1;
|
||||
*ptr = '\0';
|
||||
|
||||
do
|
||||
@@ -1814,12 +1813,11 @@ to_hex64(PG_FUNCTION_ARGS)
|
||||
{
|
||||
static char digits[] = "0123456789abcdef";
|
||||
char buf[32]; /* bigger than needed, but reasonable */
|
||||
char *ptr,
|
||||
*end;
|
||||
char *ptr;
|
||||
text *result_text;
|
||||
int64 value = PG_GETARG_INT64(0);
|
||||
|
||||
end = ptr = buf + sizeof(buf) - 1;
|
||||
ptr = buf + sizeof(buf) - 1;
|
||||
*ptr = '\0';
|
||||
|
||||
do
|
||||
|
||||
Reference in New Issue
Block a user