aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2003-12-19 04:56:54 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2003-12-19 04:56:54 +0000
commit035a7ea58409d0ba49ffdc0d5ca1bfb9c7ce0035 (patch)
tree067dcb63383f5487f650f94066c83cccff944558 /src
parentacae15faf3a4ef6e1195d4805acdda404f4e2860 (diff)
downloadpostgresql-035a7ea58409d0ba49ffdc0d5ca1bfb9c7ce0035.tar.gz
postgresql-035a7ea58409d0ba49ffdc0d5ca1bfb9c7ce0035.zip
Make to_hex() behave portably on negative input values (treat them as
unsigned integers). Per report from Jim Crate.
Diffstat (limited to 'src')
-rw-r--r--src/backend/utils/adt/varlena.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/backend/utils/adt/varlena.c b/src/backend/utils/adt/varlena.c
index 0a71ee9c57b..50f6bf1cb78 100644
--- a/src/backend/utils/adt/varlena.c
+++ b/src/backend/utils/adt/varlena.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/adt/varlena.c,v 1.106.2.1 2003/11/30 20:53:43 joe Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/varlena.c,v 1.106.2.2 2003/12/19 04:56:54 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -2230,11 +2230,11 @@ array_to_text(PG_FUNCTION_ARGS)
Datum
to_hex32(PG_FUNCTION_ARGS)
{
- static char digits[] = "0123456789abcdef";
- char buf[32]; /* bigger than needed, but reasonable */
- char *ptr;
+ uint32 value = (uint32) PG_GETARG_INT32(0);
text *result_text;
- int32 value = PG_GETARG_INT32(0);
+ char *ptr;
+ const char *digits = "0123456789abcdef";
+ char buf[32]; /* bigger than needed, but reasonable */
ptr = buf + sizeof(buf) - 1;
*ptr = '\0';
@@ -2256,11 +2256,11 @@ to_hex32(PG_FUNCTION_ARGS)
Datum
to_hex64(PG_FUNCTION_ARGS)
{
- static char digits[] = "0123456789abcdef";
- char buf[32]; /* bigger than needed, but reasonable */
- char *ptr;
+ uint64 value = (uint64) PG_GETARG_INT64(0);
text *result_text;
- int64 value = PG_GETARG_INT64(0);
+ char *ptr;
+ const char *digits = "0123456789abcdef";
+ char buf[32]; /* bigger than needed, but reasonable */
ptr = buf + sizeof(buf) - 1;
*ptr = '\0';