فهرست منبع

Set limits for regex during search (#8913)

Prevents regex searches from running for too long
Inverle 3 هفته پیش
والد
کامیت
5e18e96887
2فایلهای تغییر یافته به همراه8 افزوده شده و 1 حذف شده
  1. 4 1
      app/Models/SystemConfiguration.php
  2. 4 0
      config.default.php

+ 4 - 1
app/Models/SystemConfiguration.php

@@ -38,7 +38,10 @@ final class FreshRSS_SystemConfiguration extends Minz_Configuration {
 	public static function init(string $config_filename, ?string $default_filename = null): FreshRSS_SystemConfiguration {
 		parent::register('system', $config_filename, $default_filename);
 		try {
-			return parent::get('system');
+			$conf = parent::get('system');
+			ini_set('pcre.backtrack_limit', $conf->limits['regex_backtrack_limit']);
+			ini_set('pcre.recursion_limit', $conf->limits['regex_recursion_limit']);
+			return $conf;
 		} catch (Minz_ConfigurationNamespaceException $ex) {
 			FreshRSS::killApp($ex->getMessage());
 		}

+ 4 - 0
config.default.php

@@ -142,6 +142,10 @@ return [
 
 		# Max amount of bytes that are allowed for upload of custom favicon
 		'max_favicon_upload_size' => 1048576,	# 1 MiB
+
+		# Limits for regex, useful to limit regex during user searches
+		'regex_backtrack_limit' => 10000,
+		'regex_recursion_limit' => 100,
 	],
 
 	# Options used by cURL when making HTTP requests, e.g. when the SimplePie library retrieves feeds.