Project

General

Profile

« Previous | Next » 

Revision f72618c4

Added by Jim Pingle almost 2 years ago

Pcap: Validate+Encode count & length. Fixes #14809

View differences:

src/usr/local/www/diag_packet_capture.php
119 119
	$input_filter = ($_POST['filter'] !== null) ? intval($_POST['filter']) : null;
120 120
	if ($_POST['count'] == '0') {
121 121
		$input_count = 0;
122
	} elseif (empty($_POST['count'])) {
123
		$input_count = 1000;
124
	} elseif (!is_numericint($_POST['count'])) {
125
		$input_error[] = 'Invalid Packet Count.';
122 126
	} else {
123
		$input_count = empty($_POST['count']) ? 1000 : $_POST['count'];
127
		$input_count = intval($_POST['count']);
128
	}
129
	if (empty($_POST['length'])) {
130
		$input_length = 0;
131
	} elseif (!is_numericint($_POST['length'])) {
132
		$input_error[] = 'Invalid Packet Length.';
133
	} else {
134
		$input_length = intval($_POST['length']);
124 135
	}
125
	$input_length = empty($_POST['length']) ? 0 : $_POST['length'];
126 136
	$input_promiscuous = empty($_POST['promiscuous']) ? false : $_POST['promiscuous'];
127 137
	// view options
128 138
	$input_viewdetail = empty($_POST['viewdetail']) ? 'normal' : $_POST['viewdetail'];
......
759 769

  
760 770
		// Handle capture options
761 771
		$cmd_part_promiscuous = $input_promiscuous ? '' : ' -p';
762
		$cmd_part_count = empty($input_count) ? '' : " -c {$input_count}";
763
		$cmd_part_length = empty($input_length) ? '' : " -s {$input_length}";
772
		$cmd_part_count = empty($input_count) ? '' : " -c " . escapeshellarg($input_count);
773
		$cmd_part_length = empty($input_length) ? '' : " -s " . escapeshellarg($input_length);
764 774
		$cmd_expression_string = $expression_string ? escapeshellarg($expression_string) : '';
765 775

  
766 776
		/* Output in binary format (use packet-buffered to avoid missing packets) to stdout,

Also available in: Unified diff