Skip to content

Commit 7fc2d50

Browse files
committed
Make to_hex() behave portably on negative input values (treat them as
unsigned integers). Per report from Jim Crate.
1 parent edc7f14 commit 7fc2d50

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/backend/utils/adt/varlena.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/utils/adt/varlena.c,v 1.108 2003/11/30 20:55:09 joe Exp $
11+
* $PostgreSQL: pgsql/src/backend/utils/adt/varlena.c,v 1.109 2003/12/19 04:56:41 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -2230,11 +2230,11 @@ array_to_text(PG_FUNCTION_ARGS)
22302230
Datum
22312231
to_hex32(PG_FUNCTION_ARGS)
22322232
{
2233-
static char digits[] = "0123456789abcdef";
2234-
char buf[32]; /* bigger than needed, but reasonable */
2235-
char *ptr;
2233+
uint32 value = (uint32) PG_GETARG_INT32(0);
22362234
text *result_text;
2237-
int32 value = PG_GETARG_INT32(0);
2235+
char *ptr;
2236+
const char *digits = "0123456789abcdef";
2237+
char buf[32]; /* bigger than needed, but reasonable */
22382238

22392239
ptr = buf + sizeof(buf) - 1;
22402240
*ptr = '\0';
@@ -2256,11 +2256,11 @@ to_hex32(PG_FUNCTION_ARGS)
22562256
Datum
22572257
to_hex64(PG_FUNCTION_ARGS)
22582258
{
2259-
static char digits[] = "0123456789abcdef";
2260-
char buf[32]; /* bigger than needed, but reasonable */
2261-
char *ptr;
2259+
uint64 value = (uint64) PG_GETARG_INT64(0);
22622260
text *result_text;
2263-
int64 value = PG_GETARG_INT64(0);
2261+
char *ptr;
2262+
const char *digits = "0123456789abcdef";
2263+
char buf[32]; /* bigger than needed, but reasonable */
22642264

22652265
ptr = buf + sizeof(buf) - 1;
22662266
*ptr = '\0';

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy