From 037af6890fe6fdb84a08d3c86083e847c90ec0ad Mon Sep 17 00:00:00 2001
From: Aleksander Machniak <alec@alec.pl>
Date: Tue, 22 Oct 2013 08:17:26 -0400
Subject: [PATCH] Fix vulnerability in handling _session argument of utils/save-prefs (#1489382)

---
 program/steps/mail/move_del.inc |   24 +++++++++++-------------
 1 files changed, 11 insertions(+), 13 deletions(-)

diff --git a/program/steps/mail/move_del.inc b/program/steps/mail/move_del.inc
index 63f2744..37157b7 100644
--- a/program/steps/mail/move_del.inc
+++ b/program/steps/mail/move_del.inc
@@ -6,7 +6,10 @@
  |                                                                       |
  | This file is part of the Roundcube Webmail client                     |
  | Copyright (C) 2005-2009, The Roundcube Dev Team                       |
- | Licensed under the GNU GPL                                            |
+ |                                                                       |
+ | Licensed under the GNU General Public License version 3 or            |
+ | any later version with exceptions for skins & plugins.                |
+ | See the README file for a full license statement.                     |
  |                                                                       |
  | PURPOSE:                                                              |
  |   Move the submitted messages to a specific mailbox or delete them    |
@@ -14,9 +17,6 @@
  +-----------------------------------------------------------------------+
  | Author: Thomas Bruederli <roundcube@gmail.com>                        |
  +-----------------------------------------------------------------------+
-
- $Id$
-
 */
 
 // only process ajax requests
@@ -38,7 +38,7 @@
 
     if (!$moved) {
         // send error message
-	    if ($_POST['_from'] != 'show')
+        if ($_POST['_from'] != 'show')
             $OUTPUT->command('list_mailbox');
         rcmail_display_server_error('errormoving');
         $OUTPUT->send();
@@ -59,7 +59,7 @@
 
     if (!$del) {
         // send error message
-	    if ($_POST['_from'] != 'show')
+        if ($_POST['_from'] != 'show')
             $OUTPUT->command('list_mailbox');
         rcmail_display_server_error('errordeleting');
         $OUTPUT->send();
@@ -73,6 +73,8 @@
 }
 // unknown action or missing query param
 else {
+    $OUTPUT->show_message('internalerror', 'error');
+    $OUTPUT->send();
     exit;
 }
 
@@ -111,6 +113,7 @@
   $OUTPUT->set_env('messagecount', $msg_count);
   $OUTPUT->set_env('current_page', $page);
   $OUTPUT->set_env('pagecount', $pages);
+  $OUTPUT->set_env('exists', $RCMAIL->storage->count($mbox, 'EXISTS', true));
 
   // update mailboxlist
   $mbox = $RCMAIL->storage->get_folder();
@@ -135,11 +138,8 @@
 
   // add new rows from next page (if any)
   if ($addrows && $count && $uids != '*' && ($jump_back || $nextpage_count > 0)) {
-    $sort_col   = isset($_SESSION['sort_col'])   ? $_SESSION['sort_col']   : $CONFIG['message_sort_col'];
-    $sort_order = isset($_SESSION['sort_order']) ? $_SESSION['sort_order'] : $CONFIG['message_sort_order'];
-
-    $a_headers = $RCMAIL->storage->list_messages($mbox, NULL, $sort_col, $sort_order,
-      $jump_back ? NULL : $count);
+    $a_headers = $RCMAIL->storage->list_messages($mbox, NULL,
+      rcmail_sort_column(), rcmail_sort_order(), $jump_back ? NULL : $count);
 
     rcmail_js_message_list($a_headers, false);
   }
@@ -147,5 +147,3 @@
 
 // send response
 $OUTPUT->send();
-
-

--
Gitblit v1.9.1