mirror of
https://github.com/postgres/postgres.git
synced 2025-05-01 01:04:50 +03:00
Fix buffer overrun in to_ascii(), per report from Guido Notari.
This commit is contained in:
parent
794162bb1a
commit
ec54a6efcf
@ -1,7 +1,7 @@
|
|||||||
/* -----------------------------------------------------------------------
|
/* -----------------------------------------------------------------------
|
||||||
* ascii.c
|
* ascii.c
|
||||||
*
|
*
|
||||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/ascii.c,v 1.13 2002/08/29 07:22:26 ishii Exp $
|
* $Header: /cvsroot/pgsql/src/backend/utils/adt/ascii.c,v 1.14 2003/04/02 21:07:59 tgl Exp $
|
||||||
*
|
*
|
||||||
* Portions Copyright (c) 1999-2000, PostgreSQL Global Development Group
|
* Portions Copyright (c) 1999-2000, PostgreSQL Global Development Group
|
||||||
*
|
*
|
||||||
@ -27,9 +27,9 @@ static text *encode_to_ascii(text *data, int enc);
|
|||||||
char *
|
char *
|
||||||
pg_to_ascii(unsigned char *src, unsigned char *src_end, unsigned char *desc, int enc)
|
pg_to_ascii(unsigned char *src, unsigned char *src_end, unsigned char *desc, int enc)
|
||||||
{
|
{
|
||||||
unsigned char *x = NULL;
|
unsigned char *x;
|
||||||
unsigned char *ascii = NULL;
|
unsigned char *ascii;
|
||||||
int range = 0;
|
int range;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* relevant start for an encoding
|
* relevant start for an encoding
|
||||||
@ -66,12 +66,13 @@ pg_to_ascii(unsigned char *src, unsigned char *src_end, unsigned char *desc, int
|
|||||||
{
|
{
|
||||||
elog(ERROR, "pg_to_ascii(): unsupported encoding from %s",
|
elog(ERROR, "pg_to_ascii(): unsupported encoding from %s",
|
||||||
pg_encoding_to_char(enc));
|
pg_encoding_to_char(enc));
|
||||||
|
return NULL; /* keep compiler quiet */
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Encode
|
* Encode
|
||||||
*/
|
*/
|
||||||
for (x = src; x <= src_end; x++)
|
for (x = src; x < src_end; x++)
|
||||||
{
|
{
|
||||||
if (*x < 128)
|
if (*x < 128)
|
||||||
*desc++ = *x;
|
*desc++ = *x;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user