]> git.joonet.de Git - adminer.git/commitdiff
Avoid infinite loop
authorJakub Vrana <jakub@vrana.cz>
Fri, 5 Aug 2011 07:01:36 +0000 (09:01 +0200)
committerJakub Vrana <jakub@vrana.cz>
Fri, 5 Aug 2011 07:01:36 +0000 (09:01 +0200)
adminer/sql.inc.php

index eb0510a5b3cbfe5bd9b5f5d960afd3fee2447e1f..7165013da52c367f043d5ea329572db9cc71eb00 100644 (file)
@@ -73,8 +73,9 @@ if (!$error && $_POST) {
                                        if ($found && $found != $delimiter) { // find matching quote or comment end
                                                while (preg_match('(' . ($found == '/*' ? '\\*/' : ($found == '[' ? ']' : (ereg('^-- |^#', $found) ? "\n" : preg_quote($found) . "|\\\\."))) . '|$)s', $query, $match, PREG_OFFSET_CAPTURE, $offset)) { //! respect sql_mode NO_BACKSLASH_ESCAPES
                                                        $s = $match[0][0];
-                                                       $offset = $match[0][1] + ($s ? strlen($s) : -strlen($found)); // strlen($found) is higher than length of longest pattern minus one
+                                                       $offset = $match[0][1] + strlen($s);
                                                        if (!$s && $fp && !feof($fp)) {
+                                                               $offset -= strlen($found); // strlen($found) >= strlen("\\.") - 1
                                                                $query .= fread($fp, 1e5);
                                                        } elseif ($s[0] != "\\") {
                                                                break;