]> git.joonet.de Git - adminer.git/commitdiff
Don't crash when parsing overly long enum type
authorJakub Vrana <jakub@vrana.cz>
Thu, 18 Jul 2013 20:28:35 +0000 (13:28 -0700)
committerJakub Vrana <jakub@vrana.cz>
Thu, 18 Jul 2013 20:28:35 +0000 (13:28 -0700)
adminer/drivers/mysql.inc.php
adminer/include/editing.inc.php

index 07ccb89b6b893c1f5d64bc4a78b79ec1c92f4f80..89a3cccc7da355967fb2d7e0a64fd35d761453f9 100644 (file)
@@ -793,7 +793,7 @@ if (!defined("DRIVER")) {
        function routine($name, $type) {
                global $connection, $enum_length, $inout, $types;
                $aliases = array("bool", "boolean", "integer", "double precision", "real", "dec", "numeric", "fixed", "national char", "national varchar");
-               $type_pattern = "((" . implode("|", array_merge(array_keys($types), $aliases)) . ")\\b(?:\\s*\\(((?:[^'\")]*|$enum_length)+)\\))?\\s*(zerofill\\s*)?(unsigned(?:\\s+zerofill)?)?)(?:\\s*(?:CHARSET|CHARACTER\\s+SET)\\s*['\"]?([^'\"\\s]+)['\"]?)?";
+               $type_pattern = "((" . implode("|", array_merge(array_keys($types), $aliases)) . ")\\b(?:\\s*\\(((?:[^'\")]*|$enum_length)++)\\))?\\s*(zerofill\\s*)?(unsigned(?:\\s+zerofill)?)?)(?:\\s*(?:CHARSET|CHARACTER\\s+SET)\\s*['\"]?([^'\"\\s]+)['\"]?)?";
                $pattern = "\\s*(" . ($type == "FUNCTION" ? "" : $inout) . ")?\\s*(?:`((?:[^`]|``)*)`\\s*|\\b(\\S+)\\s+)$type_pattern";
                $create = $connection->result("SHOW CREATE $type " . idf_escape($name), 2);
                preg_match("~\\(((?:$pattern\\s*,?)*)\\)\\s*" . ($type == "FUNCTION" ? "RETURNS\\s+$type_pattern\\s+" : "") . "(.*)~is", $create, $match);
index af2c445ad0ecf3557e483aef78cc5ef5211906ae..3c74f93aa288570b4d1dd9eb90b2fdd92e82e8f7 100644 (file)
@@ -152,7 +152,7 @@ function edit_type($key, $field, $collations, $foreign_keys = array()) {
 */
 function process_length($length) {
        global $enum_length;
-       return (preg_match("~^\\s*(?:$enum_length)(?:\\s*,\\s*(?:$enum_length))*\\s*\$~", $length) && preg_match_all("~$enum_length~", $length, $matches) ? implode(",", $matches[0]) : preg_replace('~[^0-9,+-]~', '', $length));
+       return (preg_match("~^\\s*$enum_length(?:\\s*,\\s*$enum_length)*+\\s*\$~", $length) && preg_match_all("~$enum_length~", $length, $matches) ? implode(",", $matches[0]) : preg_replace('~[^0-9,+-]~', '', $length));
 }
 
 /** Create SQL string from field type