Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 7e99cea

Browse files
committed
Implement following item in TODO:
* Reject character sequences those are not valid in their charset
1 parent 95dc778 commit 7e99cea

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

src/backend/utils/adt/varchar.c

+12-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/utils/adt/varchar.c,v 1.81 2001/07/15 11:07:37 ishii Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/utils/adt/varchar.c,v 1.82 2001/09/11 05:18:59 ishii Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -75,10 +75,14 @@ bpcharin(PG_FUNCTION_ARGS)
7575
int i;
7676
#ifdef MULTIBYTE
7777
int charlen; /* number of charcters in the input string */
78+
char *ermsg;
7879
#endif
7980

8081
len = strlen(s);
8182
#ifdef MULTIBYTE
83+
if ((ermsg = pg_verifymbstr(s, len)))
84+
elog(ERROR,"%s",ermsg);
85+
8286
charlen = pg_mbstrlen(s);
8387
#endif
8488

@@ -405,8 +409,15 @@ varcharin(PG_FUNCTION_ARGS)
405409
int32 atttypmod = PG_GETARG_INT32(2);
406410
VarChar *result;
407411
size_t len, maxlen;
412+
#ifdef MULTIBYTE
413+
char *ermsg;
414+
#endif
408415

409416
len = strlen(s);
417+
#ifdef MULTIBYTE
418+
if ((ermsg = pg_verifymbstr(s, len)))
419+
elog(ERROR,"%s",ermsg);
420+
#endif
410421
maxlen = atttypmod - VARHDRSZ;
411422

412423
if (atttypmod >= (int32) VARHDRSZ && len > maxlen)

src/backend/utils/adt/varlena.c

+10-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/utils/adt/varlena.c,v 1.71 2001/08/13 18:45:35 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/utils/adt/varlena.c,v 1.72 2001/09/11 05:18:59 ishii Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -154,8 +154,17 @@ textin(PG_FUNCTION_ARGS)
154154
char *inputText = PG_GETARG_CSTRING(0);
155155
text *result;
156156
int len;
157+
#ifdef MULTIBYTE
158+
char *ermsg;
159+
#endif
157160

158161
len = strlen(inputText) + VARHDRSZ;
162+
163+
#ifdef MULTIBYTE
164+
if ((ermsg = pg_verifymbstr(inputText, len - VARHDRSZ)))
165+
elog(ERROR,"%s",ermsg);
166+
#endif
167+
159168
result = (text *) palloc(len);
160169
VARATT_SIZEP(result) = len;
161170

0 commit comments

Comments
 (0)