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

Commit 6fcd501

Browse files
committed
Add checks for valid encoding of query strings passed to SPI by plperl.
1 parent b989662 commit 6fcd501

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/pl/plperl/plperl.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**********************************************************************
22
* plperl.c - perl as a procedural language for PostgreSQL
33
*
4-
* $PostgreSQL: pgsql/src/pl/plperl/plperl.c,v 1.169 2010/02/26 02:01:33 momjian Exp $
4+
* $PostgreSQL: pgsql/src/pl/plperl/plperl.c,v 1.170 2010/03/09 02:48:33 adunstan Exp $
55
*
66
**********************************************************************/
77

@@ -2102,6 +2102,8 @@ plperl_spi_exec(char *query, int limit)
21022102
{
21032103
int spi_rv;
21042104

2105+
pg_verifymbstr(query, strlen(query), false);
2106+
21052107
spi_rv = SPI_execute(query, current_call_data->prodesc->fn_readonly,
21062108
limit);
21072109
ret_hv = plperl_spi_execute_fetch_result(SPI_tuptable, SPI_processed,
@@ -2343,6 +2345,9 @@ plperl_spi_query(char *query)
23432345
void *plan;
23442346
Portal portal;
23452347

2348+
/* Make sure the query is validly encoded */
2349+
pg_verifymbstr(query, strlen(query), false);
2350+
23462351
/* Create a cursor for the query */
23472352
plan = SPI_prepare(query, 0, NULL);
23482353
if (plan == NULL)
@@ -2549,6 +2554,9 @@ plperl_spi_prepare(char *query, int argc, SV **argv)
25492554
qdesc->argtypioparams[i] = typIOParam;
25502555
}
25512556

2557+
/* Make sure the query is validly encoded */
2558+
pg_verifymbstr(query, strlen(query), false);
2559+
25522560
/************************************************************
25532561
* Prepare the plan and check for errors
25542562
************************************************************/

0 commit comments

Comments
 (0)