Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Corrects SquidGuard sgerror.php page was allowing curl requests on TAG_BLANK_IMG. #382

Merged
merged 2 commits into from
Jul 28, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion www/pfSense-pkg-squidGuard/Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# $FreeBSD$

PORTNAME= pfSense-pkg-squidGuard
PORTVERSION= 1.16.2
PORTVERSION= 1.16.3
CATEGORIES= www
MASTER_SITES= # empty
DISTFILES= # empty
Expand Down
49 changes: 3 additions & 46 deletions www/pfSense-pkg-squidGuard/files/usr/local/www/sgerror.php
Original file line number Diff line number Diff line change
Expand Up @@ -198,41 +198,6 @@ function get_about() {
<?php
}

function filter_by_image_size($url, $val_size) {
// Load URL header
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_NOBODY, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$hd = curl_exec($ch);
curl_close($ch);

$size = 0;
$SKEY = "content-length:";
$s_tmp = strtolower($hd);
$s_tmp = str_replace("\n", " ", $s_tmp); // replace all "\n"
if (strpos($s_tmp, $SKEY) !== false) {
$s_tmp = trim(substr($s_tmp, strpos($s_tmp, $SKEY) + strlen($SKEY)));
$s_tmp = trim(substr($s_tmp, 0, strpos($s_tmp, " ")));
if (is_numeric($s_tmp))
$size = intval($s_tmp);
else $size = 0;
}

/*
* check url type and content size
* redirect to specified url
*/
if (($size !== 0) && ($size < $val_size)) {
header("HTTP/1.0");
header("Location: $url", '', 302);
} else {
// Returna blank image
header("Content-Type: image/gif;");
echo GIF_BODY;
}
}

/* ----------------------------------------------------------------------------------------------------------------------
* Check arguments
Expand Down Expand Up @@ -272,17 +237,9 @@ function filter_by_image_size($url, $val_size) {
// Output a blank page
echo get_page('');
} elseif ($url === TAG_BLANK_IMG) {
// Output a blank image
$msg = trim($msg);
if (strpos($msg, "maxlen_") !== false) {
$maxlen = intval(trim(str_replace("maxlen_", "", $url)));
filter_by_image_size($cl['u'], $maxlen);
exit();
} else {
// Return a blank image
header("Content-Type: image/gif;"); // charset=windows-1251");
echo GIF_BODY;
}
// Return a blank image
header("Content-Type: image/gif;"); // charset=windows-1251");
echo GIF_BODY;
} elseif ($err_id !== 0) {
// Output an error code
$er_msg = strstr($_GET['url'], ' ');
Expand Down