summaryrefslogtreecommitdiff
path: root/sql/set_var.cc
diff options
context:
space:
mode:
Diffstat (limited to 'sql/set_var.cc')
-rw-r--r--sql/set_var.cc70
1 files changed, 53 insertions, 17 deletions
diff --git a/sql/set_var.cc b/sql/set_var.cc
index fd81dc1a867..7d9d88f0281 100644
--- a/sql/set_var.cc
+++ b/sql/set_var.cc
@@ -1667,6 +1667,14 @@ bool sys_var::check_set(THD *thd, set_var *var, TYPELIB *enum_names)
strmov(buff, "NULL");
goto err;
}
+
+ if (!m_allow_empty_value &&
+ res->length() == 0)
+ {
+ buff[0]= 0;
+ goto err;
+ }
+
var->save_result.ulong_value= ((ulong)
find_set(enum_names, res->c_ptr(),
res->length(),
@@ -1682,10 +1690,19 @@ bool sys_var::check_set(THD *thd, set_var *var, TYPELIB *enum_names)
else
{
ulonglong tmp= var->value->val_int();
- /*
- For when the enum is made to contain 64 elements, as 1ULL<<64 is
- undefined, we guard with a "count<64" test.
- */
+
+ if (!m_allow_empty_value &&
+ tmp == 0)
+ {
+ buff[0]= '0';
+ buff[1]= 0;
+ goto err;
+ }
+
+ /*
+ For when the enum is made to contain 64 elements, as 1ULL<<64 is
+ undefined, we guard with a "count<64" test.
+ */
if (unlikely((tmp >= ((ULL(1)) << enum_names->count)) &&
(enum_names->count < 64)))
{
@@ -2385,32 +2402,51 @@ static int sys_check_log_path(THD *thd, set_var *var)
MY_STAT f_stat;
String str(buff, sizeof(buff), system_charset_info), *res;
const char *log_file_str;
-
+ size_t path_length;
+
if (!(res= var->value->val_str(&str)))
goto err;
log_file_str= res->c_ptr();
bzero(&f_stat, sizeof(MY_STAT));
- (void) unpack_filename(path, log_file_str);
- if (my_stat(path, &f_stat, MYF(0)))
+ path_length= unpack_filename(path, log_file_str);
+
+ if (!path_length)
{
- /* Check if argument is a file and we have 'write' permission */
- if (!MY_S_ISREG(f_stat.st_mode) ||
- !(f_stat.st_mode & MY_S_IWRITE))
- goto err;
+ /* File name is empty. */
+
+ goto err;
}
- else
+
+ if (my_stat(path, &f_stat, MYF(0)))
{
- size_t path_length;
/*
- Check if directory exists and
- we have permission to create file & write to file
+ A file system object exists. Check if argument is a file and we have
+ 'write' permission.
*/
- (void) dirname_part(path, log_file_str, &path_length);
- if (my_access(path, (F_OK|W_OK)))
+
+ if (!MY_S_ISREG(f_stat.st_mode) ||
+ !(f_stat.st_mode & MY_S_IWRITE))
goto err;
+
+ return 0;
}
+
+ /* Get dirname of the file path. */
+ (void) dirname_part(path, log_file_str, &path_length);
+
+ /* Dirname is empty if file path is relative. */
+ if (!path_length)
+ return 0;
+
+ /*
+ Check if directory exists and we have permission to create file and
+ write to file.
+ */
+ if (my_access(path, (F_OK|W_OK)))
+ goto err;
+
return 0;
err: