Skip to content
Snippets Groups Projects
Commit 763be7b3 authored by Maksim Kaitmazian's avatar Maksim Kaitmazian Committed by Dmitry Ivanov
Browse files

fix: allow empty password and username in MD5

It fixes the following assertion
```bash
tarantool: ./src/lib/core/crypt.c:84: md5_encrypt:
Assertion `password_len + salt_len > 0' failed.
```
caused by the following code
```lua
box.cfg{auth_type='md5'}
box.schema.user.password("")
```

NO_CHANGELOG=fix an unreleased feature
NO_DOC=fix an unreleased feature
parent 6b385e43
No related branches found
No related tags found
No related merge requests found
......@@ -81,7 +81,11 @@ void
md5_encrypt(const char *password, size_t password_len,
const char *salt, size_t salt_len, char *buf)
{
assert(password_len + salt_len > 0);
if (password_len + salt_len == 0) {
memcpy(buf, "md5", strlen("md5"));
md5_hash("", 0, buf + strlen("md5"));
return;
}
char *crypt_buf = xmalloc(password_len + salt_len);
/*
......
......@@ -15,7 +15,8 @@ end)
g.test_box_password_without_username_argument = function()
t.assert(g.server:exec(function()
box.cfg{auth_type='chap-sha1'}
t.assert_equals(box.schema.user.password("", ""),
'vhvewKp0tNyweZQ+cFKAlsyphfg=')
t.assert_equals(box.schema.user.password("qwerty", box.session.user()),
'qhQg8YLoi55fh09vvnRZKR6PRgE=')
t.assert_equals(box.schema.user.password("qwerty"),
......@@ -24,7 +25,10 @@ g.test_box_password_without_username_argument = function()
--- so the passwords must be equal
t.assert_equals(box.schema.user.password("qwerty"),
box.schema.user.password("qwerty", "???"))
box.cfg{auth_type='md5'}
t.assert_equals(box.schema.user.password("", ""),
'md5d41d8cd98f00b204e9800998ecf8427e')
t.assert_equals(box.schema.user.password("qwerty", ""),
'md5d8578edf8458ce06fbc5bb76a58c5ca4')
t.assert_equals(box.schema.user.password("qwerty"),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment