Skip to content

Commit f3ac7fc

Browse files
author
Ilia Alshanetsky
committed
Added -H option to CLI binary. This option can be used to hide any arguments
including the script name passed to the CLI binary.
1 parent beaf84e commit f3ac7fc

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

sapi/cli/php_cli.c

+14-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@
8787
extern char *ap_php_optarg;
8888
extern int ap_php_optind;
8989

90-
#define OPTSTRING "aB:Cc:d:E:eF:f:g:hilmnqR:r:sw?vz:"
90+
#define OPTSTRING "aB:Cc:d:E:eF:f:g:hilmnqRH:r:sw?vz"
9191

9292
static int print_module_info(zend_module_entry *module, void *arg TSRMLS_DC)
9393
{
@@ -317,6 +317,7 @@ static void php_cli_usage(char *argv0)
317317
" -R <code> Run PHP <code> for every input line\n"
318318
" -F <file> Parse and execute <file> for every input line\n"
319319
" -E <end_code> Run PHP <end_code> after processing all input lines\n"
320+
" -H Hide any passed arguments\n"
320321
" -s Display colour syntax highlighted source.\n"
321322
" -v Version number\n"
322323
" -w Display source with stripped comments and whitespace.\n"
@@ -471,6 +472,7 @@ int main(int argc, char *argv[])
471472
char *exec_direct=NULL, *exec_run=NULL, *exec_begin=NULL, *exec_end=NULL;
472473
const char *param_error=NULL;
473474
int scan_input = 0;
475+
int hide_argv = 0;
474476
/* end of temporary locals */
475477
#ifdef ZTS
476478
zend_compiler_globals *compiler_globals;
@@ -780,6 +782,9 @@ int main(int argc, char *argv[])
780782
case 'z': /* load extension file */
781783
zend_load_extension(ap_php_optarg);
782784
break;
785+
case 'H':
786+
hide_argv = 1;
787+
break;
783788

784789
default:
785790
break;
@@ -844,6 +849,14 @@ int main(int argc, char *argv[])
844849
}
845850
CG(start_lineno) = lineno;
846851
*arg_excp = arg_free; /* reconstuct argv */
852+
853+
if (hide_argv) {
854+
int i;
855+
for (i = 1; i < argc; i++) {
856+
memset(argv[i], 0, strlen(argv[i]));
857+
}
858+
}
859+
847860
if (no_headers) {
848861
SG(headers_sent) = 1;
849862
SG(request_info).no_headers = 1;

0 commit comments

Comments
 (0)