Skip to content

Commit 3f88b8e

Browse files
committed
Bug #19388163: PASSWORD VALIDATION PLUGIN CRASH WITH USER VARIABLE + DICTIONARY LOOKUP
The mysql_string_to_lowercase() was allocating strings for single byte csets only if the string supplied to it was not dynamically allocated. But it was freeing it unconditionally via mysql_string_free(). This function is called by the password validator when verifying against a dictionary file. Thus with certain arguments a double free was ocurring. Fixed by making sure mysql_string_to_lowercase() does always allocate a new mysql string class.
1 parent dbeb8f5 commit 3f88b8e

1 file changed

Lines changed: 3 additions & 6 deletions

File tree

sql/string_service.cc

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -141,18 +141,15 @@ mysql_string_handle mysql_string_to_lowercase(mysql_string_handle string_handle)
141141
String *str= (String *) string_handle;
142142
String *res= new String[1];
143143
const CHARSET_INFO *cs= str->charset();
144-
res->set_charset(cs);
145144
if (cs->casedn_multiply == 1)
146145
{
147-
uint len;
148-
res= copy_if_not_alloced(res, str, str->length());
149-
len= cs->cset->casedn_str(cs, (char*) res->ptr());
150-
DBUG_ASSERT(len <= res->length());
151-
res->length(len);
146+
res->copy(*str);
147+
my_casedn_str(cs, res->c_ptr_quick());
152148
}
153149
else
154150
{
155151
uint len= str->length() * cs->casedn_multiply;
152+
res->set_charset(cs);
156153
res->alloc(len);
157154
len= cs->cset->casedn(cs, (char*) str->ptr(), str->length(), (char *) res->ptr(), len);
158155
res->length(len);

0 commit comments

Comments
 (0)