Skip to content
Permalink
Browse files Browse the repository at this point in the history
[security] Fixed issue #14670 : update tcpdf to 6.2.25
Dev: security fix in 6.2.22
  • Loading branch information
Shnoulle committed Mar 22, 2019
1 parent f9f561f commit 1cdd78d
Show file tree
Hide file tree
Showing 10 changed files with 245 additions and 189 deletions.
16 changes: 14 additions & 2 deletions application/third_party/tcpdf/CHANGELOG.TXT
@@ -1,5 +1,17 @@
Unreleased
- fix Undesired mouseover effect on links in PDF on Chrome Pdf Viewer
6.2.25
- Fix support for image URLs.

6.2.24
- Support remote urls when checking if file exists.

6.2.23
- Simplify file_exists function.

6.2.22
- Fix for security vulnerability: Using the phar:// wrapper it was possible to trigger the unserialization of user provided data.

6.2.19
- Merge various fixes for PHP 7.3 compatibility and security.

6.2.13 (2016-06-10)
- IMPORTANT: A new version of this library is under development at https://github.com/tecnickcom/tc-lib-pdf and as a consequence this version will not receive any additional development or support. This version should be considered obsolete, new projects should use the new version as soon it will become stable.
Expand Down
1 change: 1 addition & 0 deletions application/third_party/tcpdf/LIMESURVEY-README.txt
@@ -0,0 +1 @@
Not updated tcpdf 6.2.25 version. Remove examples directory.
2 changes: 1 addition & 1 deletion application/third_party/tcpdf/composer.json
@@ -1,6 +1,6 @@
{
"name": "tecnickcom/tcpdf",
"version": "6.2.16",
"version": "6.2.26",
"homepage": "http://www.tcpdf.org/",
"type": "library",
"description": "TCPDF is a PHP class for generating PDF documents and barcodes.",
Expand Down
Binary file modified application/third_party/tcpdf/include/sRGB.icc
Binary file not shown.
16 changes: 10 additions & 6 deletions application/third_party/tcpdf/include/tcpdf_fonts.php
Expand Up @@ -70,7 +70,7 @@ class TCPDF_FONTS {
* @public static
*/
public static function addTTFfont($fontfile, $fonttype='', $enc='', $flags=32, $outpath='', $platid=3, $encid=1, $addcbbox=false, $link=false) {
if (!file_exists($fontfile)) {
if (!TCPDF_STATIC::file_exists($fontfile)) {
// Could not find file
return false;
}
Expand All @@ -95,7 +95,7 @@ public static function addTTFfont($fontfile, $fonttype='', $enc='', $flags=32, $
$outpath = self::_getfontpath();
}
// check if this font already exist
if (@file_exists($outpath.$font_name.'.php')) {
if (@TCPDF_STATIC::file_exists($outpath.$font_name.'.php')) {
// this font already exist (delete it from fonts folder to rebuild it)
return $font_name;
}
Expand Down Expand Up @@ -1543,11 +1543,11 @@ public static function _getfontpath() {
public static function getFontFullPath($file, $fontdir=false) {
$fontfile = '';
// search files on various directories
if (($fontdir !== false) AND @file_exists($fontdir.$file)) {
if (($fontdir !== false) AND @TCPDF_STATIC::file_exists($fontdir.$file)) {
$fontfile = $fontdir.$file;
} elseif (@file_exists(self::_getfontpath().$file)) {
} elseif (@TCPDF_STATIC::file_exists(self::_getfontpath().$file)) {
$fontfile = self::_getfontpath().$file;
} elseif (@file_exists($file)) {
} elseif (@TCPDF_STATIC::file_exists($file)) {
$fontfile = $file;
}
return $fontfile;
Expand Down Expand Up @@ -2003,7 +2003,11 @@ public static function UTF8StringToArray($str, $isunicode=true, &$currentfont) {
$chars = str_split($str);
$carr = array_map('ord', $chars);
}
$currentfont['subsetchars'] += array_fill_keys($carr, true);
if (is_array($currentfont['subsetchars']) && is_array($carr)) {
$currentfont['subsetchars'] += array_fill_keys($carr, true);
} else {
$currentfont['subsetchars'] = array_merge($currentfont['subsetchars'], $carr);
}
return $carr;
}

Expand Down
8 changes: 2 additions & 6 deletions application/third_party/tcpdf/include/tcpdf_images.php
Expand Up @@ -161,12 +161,8 @@ public static function _toJPEG($image, $quality, $tempfile) {
*/
public static function _parsejpeg($file) {
// check if is a local file
if (!@file_exists($file)) {
// try to encode spaces on filename
$tfile = str_replace(' ', '%20', $file);
if (@file_exists($tfile)) {
$file = $tfile;
}
if (!@TCPDF_STATIC::file_exists($file)) {
return false;
}
$a = getimagesize($file);
if (empty($a)) {
Expand Down
84 changes: 47 additions & 37 deletions application/third_party/tcpdf/include/tcpdf_static.php
Expand Up @@ -55,7 +55,7 @@ class TCPDF_STATIC {
* Current TCPDF version.
* @private static
*/
private static $tcpdf_version = '6.2.16';
private static $tcpdf_version = '6.2.26';

/**
* String alias for total number of pages.
Expand Down Expand Up @@ -1774,39 +1774,6 @@ public static function getVectorsAngle($x1, $y1, $x2, $y2) {
return $angle;
}

















// ====================================================================================================================
// REIMPLEMENTED
// ====================================================================================================================














/**
* Split string by a regular expression.
* This is a wrapper for the preg_split function to avoid the bug: https://bugs.php.net/bug.php?id=45850
Expand Down Expand Up @@ -1854,6 +1821,49 @@ public static function fopenLocal($filename, $mode) {
return fopen($filename, $mode);
}

/**
* Check if the URL exist.
* @param url (string) URL to check.
* @return Returns TRUE if the URL exists; FALSE otherwise.
* @public static
*/
public static function url_exists($url) {
$crs = curl_init();
curl_setopt($crs, CURLOPT_URL, $url);
curl_setopt($crs, CURLOPT_NOBODY, true);
curl_setopt($crs, CURLOPT_FAILONERROR, true);
if ((ini_get('open_basedir') == '') && (!ini_get('safe_mode'))) {
curl_setopt($crs, CURLOPT_FOLLOWLOCATION, true);
}
curl_setopt($crs, CURLOPT_CONNECTTIMEOUT, 5);
curl_setopt($crs, CURLOPT_TIMEOUT, 30);
curl_setopt($crs, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($crs, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($crs, CURLOPT_USERAGENT, 'tc-lib-file');
curl_exec($crs);
$code = curl_getinfo($crs, CURLINFO_HTTP_CODE);
curl_close($crs);
return ($code == 200);
}

/**
* Wrapper for file_exists.
* Checks whether a file or directory exists.
* Only allows some protocols and local files.
* @param filename (string) Path to the file or directory.
* @return Returns TRUE if the file or directory specified by filename exists; FALSE otherwise.
* @public static
*/
public static function file_exists($filename) {
if (preg_match('|^https?://|', $filename) == 1) {
return self::url_exists($filename);
}
if (strpos($filename, '://')) {
return false; // only support http and https wrappers for security reasons
}
return @file_exists($filename);
}

/**
* Reads entire file into a string.
* The file can be also an URL.
Expand Down Expand Up @@ -1914,8 +1924,10 @@ public static function fileGetContents($file) {
}
//
$alt = array_unique($alt);
//var_dump($alt);exit;//DEBUG
foreach ($alt as $path) {
if (!self::file_exists($path)) {
return false;
}
$ret = @file_get_contents($path);
if ($ret !== false) {
return $ret;
Expand Down Expand Up @@ -1949,8 +1961,6 @@ public static function fileGetContents($file) {
return false;
}



/**
* Get ULONG from string (Big Endian 32-bit unsigned integer).
* @param $str (string) string from where to extract value
Expand Down

0 comments on commit 1cdd78d

Please sign in to comment.