Project

General

Profile

Actions

Bug #9074

closed

Alias URL lists only storing last-most list in config.

Added by Paul Bramhall about 6 years ago. Updated over 5 years ago.

Status:
Resolved
Priority:
Normal
Category:
Aliases / Tables
Target version:
Start date:
10/28/2018
Due date:
% Done:

100%

Estimated time:
Plus Target Version:
Release Notes:
Affected Version:
2.4.x
Affected Architecture:
All

Description

When creating an Alias URL list under Firewall->Aliases->URLs, only the IP's from the last-most URL in the list is what is stored in the /cf/conf/config.xml file. The other previous URLs in the list, even though correctly validated & checked, are not kept.

It looks as though the issue lies within the /usr/local/www/firewall_aliases_edit.php file. The issue appears to be that during the loop where each url is downloaded & parsed, the $addresses array is replaced & not appended to when each URL is pulled in & validated. (lines 292 to 299)

 if (file_exists("{$temp_filename}/aliases")) {
         $address = parse_aliases_file("{$temp_filename}/aliases", $_POST['type'], 5000);
         if ($address == null) {
                 /* nothing was found */
                 $input_errors[] = sprintf(gettext("A valid URL must be provided. Could not fetch usable data from '%s'."), $_POST['address' . $x]);
         }
         mwexec("/bin/rm -rf " . escapeshellarg($temp_filename));
 } else {

The following patch solves the issue for me, where the array is appended during each iteration.

@@ -253,6 +253,7 @@
         for ($x = 0; $x < $max_alias_addresses - 1; $x++) {
             $_POST['address' . $x] = trim($_POST['address' . $x]);
             if ($_POST['address' . $x]) {
+                $t_address = array();
                 /* fetch down and add in */
                 $temp_filename = tempnam("{$g['tmp_path']}/", "alias_import");
                 unlink_if_exists($temp_filename);
@@ -290,10 +291,13 @@
                 }

                 if (file_exists("{$temp_filename}/aliases")) {
-                    $address = parse_aliases_file("{$temp_filename}/aliases", $_POST['type'], 5000);
-                    if ($address == null) {
+                    $t_address = parse_aliases_file("{$temp_filename}/aliases", $_POST['type'], 5000);
+                    if ($t_address == null) {
                         /* nothing was found */
                         $input_errors[] = sprintf(gettext("A valid URL must be provided. Could not fetch usable data from '%s'."), $_POST['address' . $x]);
+                    } else {
+                        $address += $t_address;
                     }
+                    unset($t_address);
                      mwexec("/bin/rm -rf " . escapeshellarg($temp_filename));
                 } else {
```                     mwexec("/bin/rm -rf " . escapeshellarg($temp_filename));
                 } else {

Actions

Also available in: Atom PDF