Uploaded image for project: 'phpBB3'
  1. phpBB3
  2. PHPBB3-9643

DB connection error when $dbhost is an IPv6 address

    Details

    • Type: Bug
    • Status: Unverified Fix
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 3.0.7-PL1
    • Fix Version/s: 3.0.8-RC1
    • Labels:
      None
    • Environment:
      Linux 2.6.32-gentoo-r7, PHP 5.2.13-pl0-gentoo, PostgreSQL 8.4.4, Apache 2.2.15

      Description

      IPv6 addresses (::1 for example) containing ':' characters, that interpreting by include/db/postgres.php as host:port separator.
      There's a possible patch that fixes it:

      postgres.php

      --- postgres.php.orig   2010-06-08 18:50:44.000000000 +0400
      +++ postgres.php        2010-06-08 18:50:38.000000000 +0400
      @@ -46,7 +46,7 @@
       
                      if ($sqlserver)
                      {
      -                       if (strpos($sqlserver, ':') !== false)
      +                       if ($port === false && substr_count($sqlserver, ':') === 1)
                              {
                                      list($sqlserver, $port) = explode(':', $sqlserver);
                              }
      

        Activity

        Hide
        bantu Andreas Fischer added a comment -

        The patch is okay, but doesn't allow an ipv6 address ($dbhost) to carry a port. I wonder why we allow $dbhost to carry a port anyway, since we have $dbport.

        Show
        bantu Andreas Fischer added a comment - The patch is okay, but doesn't allow an ipv6 address ($dbhost) to carry a port. I wonder why we allow $dbhost to carry a port anyway, since we have $dbport.
        Hide
        tolich tolich added a comment -

        For compatibility purposes, IMHO.
        Anyway at this time nobody use [ip6addr]:port syntax, because it doesn't work at all.
        I think it's nothing wrong about ipv6 host/port to be provided separatelly only.

        Show
        tolich tolich added a comment - For compatibility purposes, IMHO. Anyway at this time nobody use [ip6addr] :port syntax, because it doesn't work at all. I think it's nothing wrong about ipv6 host/port to be provided separatelly only.
        Hide
        bantu Andreas Fischer added a comment -

        Yeah, I'm all for removing it completely. But that would break backward compatibility which however would be trivial to resolve.

        Show
        bantu Andreas Fischer added a comment - Yeah, I'm all for removing it completely. But that would break backward compatibility which however would be trivial to resolve.
        Hide
        bantu Andreas Fischer added a comment -

        Oh, I missunderstood. You're right, let's only drop support for port in $dbhost for ipv6.

        Show
        bantu Andreas Fischer added a comment - Oh, I missunderstood. You're right, let's only drop support for port in $dbhost for ipv6.
        Hide
        bantu Andreas Fischer added a comment -

        Using $port === false does not work because $port is passed as an empty string from config.php. Using $port in the if statement also changes the order in which the ports are taken. Currently, the port passed in $sqlserver overwrites the $port variable, which should be kept for compatibility reasons.

        Let me know if you're okay with the patch.

        Show
        bantu Andreas Fischer added a comment - Using $port === false does not work because $port is passed as an empty string from config.php. Using $port in the if statement also changes the order in which the ports are taken. Currently, the port passed in $sqlserver overwrites the $port variable, which should be kept for compatibility reasons. Let me know if you're okay with the patch.
        Hide
        tolich tolich added a comment -

        Yes, it works.

        Show
        tolich tolich added a comment - Yes, it works.

          People

          • Assignee:
            bantu Andreas Fischer
            Reporter:
            tolich tolich
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development