Skip to content

Commit f8d65ec

Browse files
author
Marc Delisle
committed
[security] Code execution vulnerability
1 parent 4680cab commit f8d65ec

File tree

2 files changed

+35
-19
lines changed

2 files changed

+35
-19
lines changed

ChangeLog

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,12 @@ $HeadURL: https://phpmyadmin.svn.sourceforge.net/svnroot/phpmyadmin/trunk/phpMyA
88
2.11.10.0 (not yet released)
99
- [core] safer handling of temporary files with open_basedir (thanks to Thijs
1010
Kinkhorst)
11-
- [core] do not automatically set and create TempDir, it might lead to secrity
11+
- [core] do not automatically set and create TempDir, it might lead to security
1212
issue (thanks to Thijs Kinkhorst)
1313

14+
2.11.9.1 (2008-09-15)
15+
- [security] Code execution vulnerability, thanks to Norman Hippert
16+
1417
2.11.9.0 (2008-08-28)
1518
- bug #2031221 [auth] Links to version number on login screen
1619
- bug #2032707 [core] PMA does not start if ini_set() is disabled

libraries/database_interface.lib.php

Lines changed: 31 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,32 @@ function PMA_DBI_get_tables($database, $link = null)
187187
null, 0, $link, PMA_DBI_QUERY_STORE);
188188
}
189189

190+
/**
191+
* usort comparison callback
192+
*
193+
* @param string $a first argument to sort
194+
* @param string $b second argument to sort
195+
*
196+
* @return integer a value representing whether $a should be before $b in the
197+
* sorted array or not
198+
*
199+
* @global string the column the array shall be sorted by
200+
* @global string the sorting order ('ASC' or 'DESC')
201+
*
202+
* @access private
203+
*/
204+
function PMA_usort_comparison_callback($a, $b)
205+
{
206+
if ($GLOBALS['cfg']['NaturalOrder']) {
207+
$sorter = 'strnatcasecmp';
208+
} else {
209+
$sorter = 'strcasecmp';
210+
}
211+
// produces f.e.:
212+
// return -1 * strnatcasecmp($a["SCHEMA_TABLES"], $b["SCHEMA_TABLES"])
213+
return ($GLOBALS['callback_sort_order'] == 'ASC' ? 1 : -1) * $sorter($a[$GLOBALS['callback_sort_by']], $b[$GLOBALS['callback_sort_by']]);
214+
} // end of the 'PMA_usort_comparison_callback()' function
215+
190216
/**
191217
* returns array of all tables in given db or dbs
192218
* this function expects unquoted names:
@@ -399,7 +425,7 @@ function PMA_DBI_get_tables_full($database, $table = false,
399425
* @param string $databases database
400426
* @param boolean $force_stats retrieve stats also for MySQL < 5
401427
* @param resource $link mysql link
402-
* @param string $sort_by collumn to order by
428+
* @param string $sort_by column to order by
403429
* @param string $sort_order ASC or DESC
404430
* @param integer $limit_offset starting offset for LIMIT
405431
* @param bool|int $limit_count row count for LIMIT or true for $GLOBALS['cfg']['MaxDbList']
@@ -543,23 +569,10 @@ function PMA_DBI_get_databases_full($database = null, $force_stats = false,
543569
* (caused by older MySQL < 5 or $GLOBALS['cfg']['NaturalOrder'])
544570
*/
545571
if ($apply_limit_and_order_manual) {
546-
547-
/**
548-
* first apply ordering
549-
*/
550-
if ($GLOBALS['cfg']['NaturalOrder']) {
551-
$sorter = 'strnatcasecmp';
552-
} else {
553-
$sorter = 'strcasecmp';
554-
}
555-
556-
// produces f.e.:
557-
// return -1 * strnatcasecmp($a["SCHEMA_TABLES"], $b["SCHEMA_TABLES"])
558-
$sort_function = '
559-
return ' . ($sort_order == 'ASC' ? 1 : -1) . ' * ' . $sorter . '($a["' . $sort_by . '"], $b["' . $sort_by . '"]);
560-
';
561-
562-
usort($databases, create_function('$a, $b', $sort_function));
572+
$GLOBALS['callback_sort_order'] = $sort_order;
573+
$GLOBALS['callback_sort_by'] = $sort_by;
574+
usort($databases, 'PMA_usort_comparison_callback');
575+
unset($GLOBALS['callback_sort_order'], $GLOBALS['callback_sort_by']);
563576

564577
/**
565578
* now apply limit

0 commit comments

Comments
 (0)