Uploaded image for project: 'phpBB'
  1. phpBB
  2. PHPBB-14245

Adding a new attachment extensions group in the ACP can cause SQLServer integer overflow

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Major Major
    • None
    • 3.1.6
    • ACP
    • None
    • SQLServer

      In certain circumstances when SQLServer is the database, if a new attachment group is added, the result can cause a database integer overflow error trying to store the integer to the database. See attachment. I developed a workaround which is not portable which involves using the SQL CAST statement, similar to issue PHPBB3-14209 for /phpbb/db/driver/driver.php. I modified these lines starting at line 687:

      		else
      		{
      			// Patch by Mark D. Hamill, phpbbservices.com, as a workaround for SQLServer
      			//return (is_bool($var)) ? intval($var) : $var;
      			return (is_bool($var) || is_numeric($var)) ? 'CAST (' . (int) $var . ' AS bigint)' : $var;
      		}
      

      In addition, a similar error can occur if the manage attachments link is clicked on in the ACP and SQLServer is the database. I was able to patch it with this code in /includes/acp/acp_attachments.php around line 1273:

      		// Patch by Mark D. Hamill, phpbbservices.com, as a workaround for SQLServer
      		//$sql = 'SELECT COUNT(a.attach_id) AS num_files, SUM(a.filesize) AS upload_dir_size
      		$sql = 'SELECT COUNT(CAST(a.attach_id AS bigint)) AS num_files, SUM(CAST (a.filesize AS bigint)) AS upload_dir_size
      			FROM ' . ATTACHMENTS_TABLE . " a
      			WHERE a.is_orphan = 0
      				$limit";
      

            Unassigned Unassigned
            MarkDHamill MarkDHamill
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: