Skip to content

Commit 4a0bee9

Browse files
committed
Adjust safety restrictions for plperl functions. Andrew Dunstan's
patch, but allow srand and disallow sprintf as per subsequent discussion.
1 parent bb85f1b commit 4a0bee9

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

src/pl/plperl/plperl.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
* ENHANCEMENTS, OR MODIFICATIONS.
3434
*
3535
* IDENTIFICATION
36-
* $PostgreSQL: pgsql/src/pl/plperl/plperl.c,v 1.55 2004/10/15 17:08:26 momjian Exp $
36+
* $PostgreSQL: pgsql/src/pl/plperl/plperl.c,v 1.56 2004/11/16 22:05:22 tgl Exp $
3737
*
3838
**********************************************************************/
3939

@@ -250,17 +250,20 @@ plperl_safe_init(void)
250250

251251
static char *safe_ok =
252252
"use vars qw($PLContainer); $PLContainer = new Safe('PLPerl');"
253-
"$PLContainer->permit_only(':default');$PLContainer->permit(':base_math');"
254-
"$PLContainer->share(qw[&elog &spi_exec_query &DEBUG &LOG &INFO &NOTICE &WARNING &ERROR %SHARED ]);"
253+
"$PLContainer->permit_only(':default');"
254+
"$PLContainer->permit(qw[:base_math !:base_io sort time]);"
255+
"$PLContainer->share(qw[&elog &spi_exec_query &DEBUG &LOG "
256+
"&INFO &NOTICE &WARNING &ERROR %SHARED ]);"
255257
"sub ::mksafefunc { return $PLContainer->reval(qq[sub { $_[0] $_[1]}]); }"
256258
;
257259

258260
static char *safe_bad =
259261
"use vars qw($PLContainer); $PLContainer = new Safe('PLPerl');"
260-
"$PLContainer->permit_only(':default');$PLContainer->permit(':base_math');"
261-
"$PLContainer->share(qw[&elog &DEBUG &LOG &INFO &NOTICE &WARNING &ERROR %SHARED ]);"
262+
"$PLContainer->permit_only(':default');"
263+
"$PLContainer->share(qw[&elog &ERROR ]);"
262264
"sub ::mksafefunc { return $PLContainer->reval(qq[sub { "
263-
"elog(ERROR,'trusted perl functions disabled - please upgrade perl Safe module to at least 2.09');}]); }"
265+
"elog(ERROR,'trusted perl functions disabled - "
266+
"please upgrade perl Safe module to at least 2.09');}]); }"
264267
;
265268

266269
SV *res;

0 commit comments

Comments
 (0)