From c7dc601156c30217f2919193d600bdd1c760f931 Mon Sep 17 00:00:00 2001 From: Marc Delisle Date: Sun, 9 Oct 2005 11:32:27 +0000 Subject: [PATCH] bug #1226819, Accepting Negative values in Resource Limits in Privileges --- ChangeLog | 2 ++ server_privileges.php | 33 +++++++++++++++++++++------------ 2 files changed, 23 insertions(+), 12 deletions(-) diff --git a/ChangeLog b/ChangeLog index 602fc5214..f616ac3f9 100755 --- a/ChangeLog +++ b/ChangeLog @@ -8,6 +8,8 @@ $Source$ 2005-10-09 Marc Delisle * tbl_properties_links.php: invalid js confirmation and operation feedback when dropping a view + * server_privileges.php: bug #1226819, Accepting Negative values in + Resource Limits in Privileges 2005-10-09 Michal Čihař * libraries/display_export.lib.php, libraries/export/sql.php, lang/*, diff --git a/server_privileges.php b/server_privileges.php index 5058fb6ea..d8d0a9156 100644 --- a/server_privileges.php +++ b/server_privileges.php @@ -689,22 +689,27 @@ if (!empty($adduser_submit) || !empty($change_copy)) { } if (PMA_MYSQL_INT_VERSION >= 40002) { if (isset($max_questions)) { - $real_sql_query .= ' MAX_QUERIES_PER_HOUR ' . (int)$max_questions; - $sql_query .= ' MAX_QUERIES_PER_HOUR ' . (int)$max_questions; + // avoid negative values + $max_questions = max(0, (int)$max_questions); + $real_sql_query .= ' MAX_QUERIES_PER_HOUR ' . $max_questions; + $sql_query .= ' MAX_QUERIES_PER_HOUR ' . $max_questions; } if (isset($max_connections)) { - $real_sql_query .= ' MAX_CONNECTIONS_PER_HOUR ' . (int)$max_connections; - $sql_query .= ' MAX_CONNECTIONS_PER_HOUR ' . (int)$max_connections; + $max_connections = max(0, (int)$max_connections); + $real_sql_query .= ' MAX_CONNECTIONS_PER_HOUR ' . $max_connections; + $sql_query .= ' MAX_CONNECTIONS_PER_HOUR ' . $max_connections; } if (isset($max_updates)) { - $real_sql_query .= ' MAX_UPDATES_PER_HOUR ' . (int)$max_updates; - $sql_query .= ' MAX_UPDATES_PER_HOUR ' . (int)$max_updates; + $max_updates = max(0, (int)$max_updates); + $real_sql_query .= ' MAX_UPDATES_PER_HOUR ' . $max_updates; + $sql_query .= ' MAX_UPDATES_PER_HOUR ' . $max_updates; } } if (PMA_MYSQL_INT_VERSION >= 50003) { if (isset($max_user_connections)) { - $real_sql_query .= ' MAX_USER_CONNECTIONS ' . (int)$max_user_connections; - $sql_query .= ' MAX_USER_CONNECTIONS ' . (int)$max_user_connections; + $max_user_connections = max(0, (int)$max_user_connections); + $real_sql_query .= ' MAX_USER_CONNECTIONS ' . $max_user_connections; + $sql_query .= ' MAX_USER_CONNECTIONS ' . $max_user_connections; } } } @@ -825,18 +830,22 @@ if (!empty($update_privs)) { } if (PMA_MYSQL_INT_VERSION >= 40002) { if (isset($max_questions)) { - $sql_query2 .= ' MAX_QUERIES_PER_HOUR ' . (int)$max_questions; + $max_questions = max(0, (int)$max_questions); + $sql_query2 .= ' MAX_QUERIES_PER_HOUR ' . $max_questions; } if (isset($max_connections)) { - $sql_query2 .= ' MAX_CONNECTIONS_PER_HOUR ' . (int)$max_connections; + $max_connections = max(0, (int)$max_connections); + $sql_query2 .= ' MAX_CONNECTIONS_PER_HOUR ' . $max_connections; } if (isset($max_updates)) { - $sql_query2 .= ' MAX_UPDATES_PER_HOUR ' . (int)$max_updates; + $max_updates = max(0, (int)$max_updates); + $sql_query2 .= ' MAX_UPDATES_PER_HOUR ' . $max_updates; } } if (PMA_MYSQL_INT_VERSION >= 50003) { if (isset($max_user_connections)) { - $sql_query2 .= ' MAX_USER_CONNECTIONS ' . (int)$max_user_connections; + $max_user_connections = max(0, (int)$max_user_connections); + $sql_query2 .= ' MAX_USER_CONNECTIONS ' . $max_user_connections; } } }