diff options
| author | Mats Kindahl <mats.kindahl@oracle.com> | 2010-12-01 23:15:14 +0100 |
|---|---|---|
| committer | Mats Kindahl <mats.kindahl@oracle.com> | 2010-12-01 23:15:14 +0100 |
| commit | 8ea491e7209cfcd6bd1927bfd7f0fe562fe20bde (patch) | |
| tree | ab144a9f86544eba0ab643cb71fab11e96ee6246 /sql/sql_plugin.cc | |
| parent | 5dd0cf1c843835d4aae282f311adb97943e9492c (diff) | |
| parent | bfb43fb44f070e72ac971c1295bcfe525afa23af (diff) | |
| download | mariadb-git-8ea491e7209cfcd6bd1927bfd7f0fe562fe20bde.tar.gz | |
Merging patch for BUG#58246 into mysql-5.5-bugteam.
Diffstat (limited to 'sql/sql_plugin.cc')
| -rw-r--r-- | sql/sql_plugin.cc | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/sql/sql_plugin.cc b/sql/sql_plugin.cc index 0fe89cd3748..5b53ca9d8b6 100644 --- a/sql/sql_plugin.cc +++ b/sql/sql_plugin.cc @@ -280,6 +280,26 @@ static void report_error(int where_to, uint error, ...) } } +/** + Check if the provided path is valid in the sense that it does cause + a relative reference outside the directory. + + @note Currently, this function only check if there are any + characters in FN_DIRSEP in the string, but it might change in the + future. + + @code + check_valid_path("../foo.so") -> true + check_valid_path("foo.so") -> false + @endcode + */ +bool check_valid_path(const char *path, size_t len) +{ + size_t prefix= my_strcspn(files_charset_info, path, path + len, FN_DIRSEP); + return prefix < len; +} + + /**************************************************************************** Value type thunks, allows the C world to play in the C++ world ****************************************************************************/ @@ -408,13 +428,14 @@ static st_plugin_dl *plugin_dl_add(const LEX_STRING *dl, int report) struct st_plugin_dl *tmp, plugin_dl; void *sym; DBUG_ENTER("plugin_dl_add"); + DBUG_PRINT("enter", ("dl->str: '%s', dl->length: %d", dl->str, dl->length)); plugin_dir_len= strlen(opt_plugin_dir); /* Ensure that the dll doesn't have a path. This is done to ensure that only approved libraries from the plugin directory are used (to make this even remotely secure). */ - if (my_strchr(files_charset_info, dl->str, dl->str + dl->length, FN_LIBCHAR) || + if (check_valid_path(dl->str, dl->length) || check_string_char_length((LEX_STRING *) dl, "", NAME_CHAR_LEN, system_charset_info, 1) || plugin_dir_len + dl->length + 1 >= FN_REFLEN) |
