Aleksander Machniak
2013-05-06 78c270c9f259c33b703cfb26b96b8dbb062db21e
Fix bugs caught by static analysis
13 files modified
45 ■■■■ changed files
plugins/acl/acl.php 5 ●●●●● patch | view | raw | blame | history
plugins/password/drivers/sql.php 2 ●●● patch | view | raw | blame | history
program/lib/Roundcube/rcube_addressbook.php 3 ●●●● patch | view | raw | blame | history
program/lib/Roundcube/rcube_db_mysql.php 2 ●●● patch | view | raw | blame | history
program/lib/Roundcube/rcube_imap.php 4 ●●●● patch | view | raw | blame | history
program/lib/Roundcube/rcube_imap_generic.php 8 ●●●● patch | view | raw | blame | history
program/lib/Roundcube/rcube_spellchecker.php 2 ●●● patch | view | raw | blame | history
program/lib/Roundcube/rcube_vcard.php 2 ●●● patch | view | raw | blame | history
program/lib/utf8.class.php 4 ●●●● patch | view | raw | blame | history
program/steps/addressbook/func.inc 2 ●●● patch | view | raw | blame | history
program/steps/addressbook/import.inc 4 ●●●● patch | view | raw | blame | history
program/steps/addressbook/show.inc 2 ●●● patch | view | raw | blame | history
program/steps/mail/compose.inc 5 ●●●●● patch | view | raw | blame | history
plugins/acl/acl.php
@@ -433,8 +433,9 @@
        $acl   = trim(get_input_value('_acl', RCUBE_INPUT_GPC));
        $oldid = trim(get_input_value('_old', RCUBE_INPUT_GPC));
        $acl   = array_intersect(str_split($acl), $this->rights_supported());
        $users = $oldid ? array($user) : explode(',', $user);
        $acl    = array_intersect(str_split($acl), $this->rights_supported());
        $users  = $oldid ? array($user) : explode(',', $user);
        $result = 0;
        foreach ($users as $user) {
            $user = trim($user);
plugins/password/drivers/sql.php
@@ -183,7 +183,7 @@
        $res = $db->query($sql, $sql_vars);
        if (!$db->is_error()) {
            if (strtolower(substr(trim($query),0,6))=='select') {
            if (strtolower(substr(trim($sql),0,6)) == 'select') {
                if ($result = $db->fetch_array($res))
                    return PASSWORD_SUCCESS;
            } else {
program/lib/Roundcube/rcube_addressbook.php
@@ -535,7 +535,7 @@
     */
    public static function compose_contact_key($contact, $sort_col)
    {
        $key = $contact[$sort_col] . ':' . $row['sourceid'];
        $key = $contact[$sort_col] . ':' . $contact['sourceid'];
        // add email to a key to not skip contacts with the same name (#1488375)
        if (!empty($contact['email'])) {
@@ -544,7 +544,6 @@
         return $key;
    }
    /**
     * Compare search value with contact data
program/lib/Roundcube/rcube_db_mysql.php
@@ -147,7 +147,7 @@
            $result = $this->query('SHOW VARIABLES');
            while ($sql_arr = $this->fetch_array($result)) {
            while ($row = $this->fetch_array($result)) {
                $this->variables[$row[0]] = $row[1];
            }
        }
program/lib/Roundcube/rcube_imap.php
@@ -981,7 +981,7 @@
            // use memory less expensive (and quick) method for big result set
            $index = clone $this->index('', $this->sort_field, $this->sort_order);
            // get messages uids for one page...
            $index->slice($start_msg, min($cnt-$from, $this->page_size));
            $index->slice($from, min($cnt-$from, $this->page_size));
            if ($slice) {
                $index->slice(-$slice, $slice);
@@ -2726,7 +2726,7 @@
        // filter folders list according to rights requirements
        if ($rights && $this->get_capability('ACL')) {
            $a_folders = $this->filter_rights($a_folders, $rights);
            $a_mboxes = $this->filter_rights($a_mboxes, $rights);
        }
        // filter folders and sort them
program/lib/Roundcube/rcube_imap_generic.php
@@ -1077,7 +1077,7 @@
        }
        if (!$this->data['READ-WRITE']) {
            $this->setError(self::ERROR_READONLY, "Mailbox is read-only", 'EXPUNGE');
            $this->setError(self::ERROR_READONLY, "Mailbox is read-only");
            return false;
        }
@@ -1933,7 +1933,7 @@
        }
        if (!$this->data['READ-WRITE']) {
            $this->setError(self::ERROR_READONLY, "Mailbox is read-only", 'STORE');
            $this->setError(self::ERROR_READONLY, "Mailbox is read-only");
            return false;
        }
@@ -1995,7 +1995,7 @@
        }
        if (!$this->data['READ-WRITE']) {
            $this->setError(self::ERROR_READONLY, "Mailbox is read-only", 'STORE');
            $this->setError(self::ERROR_READONLY, "Mailbox is read-only");
            return false;
        }
@@ -2480,7 +2480,7 @@
                $tokens = $this->tokenizeResponse(preg_replace('/(^\(|\)$)/', '', $line));
                for ($i=0; $i<count($tokens); $i+=2) {
                    if (preg_match('/^(BODY|BINARY)/i', $token)) {
                    if (preg_match('/^(BODY|BINARY)/i', $tokens[$i])) {
                        $result = $tokens[$i+1];
                        $found  = true;
                        break;
program/lib/Roundcube/rcube_spellchecker.php
@@ -588,7 +588,7 @@
        if (empty($plugin['abort'])) {
            $dict = array();
            $this->rc->db->query(
            $sql_result = $this->rc->db->query(
                "SELECT data FROM ".$this->rc->db->table_name('dictionary')
                ." WHERE user_id ". ($plugin['userid'] ? "= ".$this->rc->db->quote($plugin['userid']) : "IS NULL")
                    ." AND " . $this->rc->db->quoteIdentifier('language') . " = ?",
program/lib/Roundcube/rcube_vcard.php
@@ -90,7 +90,7 @@
     */
    public function __construct($vcard = null, $charset = RCUBE_CHARSET, $detect = false, $fieldmap = array())
    {
        if (!empty($fielmap)) {
        if (!empty($fieldmap)) {
            $this->extend_fieldmap($fieldmap);
        }
program/lib/utf8.class.php
@@ -60,8 +60,8 @@
  function loadCharset($charset) {
    
    $charset = preg_replace(array('/^WINDOWS-*125([0-8])$/', '/^CP-/'), array('CP125\\1', 'CP'), $charset);
    if (isset($aliases[$charset]))
      $charset = $aliases[$charset];
    if (isset($this->aliases[$charset]))
      $charset = $this->aliases[$charset];
    
    $this->charset = $charset;
program/steps/addressbook/func.inc
@@ -167,7 +167,7 @@
    // get address book name (for display)
    if ($abook && $_SESSION['addressbooks_count'] > 1) {
        $name = $abook->get_name();
        if (!$name && $source == 0) {
        if (!$name) {
            $name = rcube_label('personaladrbook');
        }
        $OUTPUT->set_env('sourcename', html_entity_decode($name, ENT_COMPAT, 'UTF-8'));
program/steps/addressbook/import.inc
@@ -88,7 +88,7 @@
  $content = html::p(null, rcube_label(array(
      'name' => 'importconfirm',
      'nr' => $IMORT_STATS->inserted,
      'nr' => $IMPORT_STATS->inserted,
      'vars' => $vars,
    )) . ($IMPORT_STATS->names ? ':' : '.'));
@@ -98,7 +98,7 @@
  if ($IMPORT_STATS->skipped) {
      $content .= html::p(null, rcube_label(array(
          'name' => 'importconfirmskipped',
          'nr' => $IMORT_STATS->skipped,
          'nr' => $IMPORT_STATS->skipped,
          'vars' => $vars,
        )) . ':');
      $content .= html::p('em', join(', ', array_map('Q', $IMPORT_STATS->skipped_names)));
program/steps/addressbook/show.inc
@@ -223,7 +223,7 @@
    }
    $hiddenfields = new html_hiddenfield(array('name' => '_source', 'value' => get_input_value('_source', RCUBE_INPUT_GPC)));
    $hiddenfields->add(array('name' => '_cid', 'value' => $record['ID']));
    $hiddenfields->add(array('name' => '_cid', 'value' => $contact_id));
    $form_start = $RCMAIL->output->request_form(array(
        'name' => "form", 'method' => "post",
program/steps/mail/compose.inc
@@ -630,7 +630,7 @@
function rcmail_compose_part_body($part, $isHtml = false)
{
    global $RCMAIL, $MESSAGE, $compose_mode;
    global $RCMAIL, $MESSAGE, $LINE_LENGTH, $compose_mode;
    // Check if we have enough memory to handle the message in it
    // #1487424: we need up to 10x more memory than the body
@@ -1212,10 +1212,11 @@
  // handle attachments in memory
  $data = file_get_contents($path);
  $name = rcmail_basename($path);
  $attachment = array(
    'group' => $COMPOSE['id'],
    'name' => rcmail_basename($path),
    'name' => $name,
    'mimetype' => $mimetype ? $mimetype : rc_mime_content_type($path, $name),
    'data' => $data,
    'size' => strlen($data),