Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MariaDB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
e96a3147
Commit
e96a3147
authored
Jan 02, 2003
by
unknown
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SCRUM password() function changes.
sql/item_strfunc.cc: Fix password() function according Monty's comment
parent
9b1dc40e
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
6 deletions
+14
-6
sql/item_strfunc.cc
sql/item_strfunc.cc
+14
-6
No files found.
sql/item_strfunc.cc
View file @
e96a3147
...
...
@@ -1281,12 +1281,12 @@ String *Item_func_password::val_str(String *str)
struct
rand_struct
rand_st
;
// local structure for 2 param version
ulong
seed
=
0
;
// seed to initialise random generator to
String
*
res
=
args
[
0
]
->
val_str
(
str
);
if
((
null_value
=
args
[
0
]
->
null_value
))
return
0
;
if
(
arg_count
==
1
)
{
String
*
res
=
args
[
0
]
->
val_str
(
str
);
if
(
res
->
length
()
==
0
)
return
&
empty_string
;
make_scrambled_password
(
tmp_value
,
res
->
c_ptr
(),
opt_old_passwords
,
...
...
@@ -1296,22 +1296,30 @@ String *Item_func_password::val_str(String *str)
}
else
{
/* We'll need the buffer to get second parameter */
char
key_buff
[
80
];
String
tmp_key_value
(
key_buff
,
sizeof
(
key_buff
),
system_charset_info
);
String
*
key
=
args
[
1
]
->
val_str
(
&
tmp_key_value
);
/* Check second argument for NULL value. First one is already checked */
if
((
null_value
=
args
[
1
]
->
null_value
))
return
0
;
/* This shall be done after checking for null for proper results */
if
(
res
->
length
()
==
0
)
return
&
empty_string
;
/* Generate the seed first this allows to avoid double allocation */
char
*
seed_ptr
=
args
[
1
]
->
val_str
(
str
)
->
c_ptr
();
char
*
seed_ptr
=
key
->
c_ptr
();
while
(
*
seed_ptr
)
{
seed
=
seed
*
211
+*
seed_ptr
;
/* Use simple hashing */
seed_ptr
++
;
}
/* Use constants which allow nice random values even with small seed */
randominit
(
&
rand_st
,
seed
*
111111
+
33333333L
,
seed
*
1111
+
55555555L
);
String
*
res
=
args
[
0
]
->
val_str
(
str
);
if
(
res
->
length
()
==
0
)
return
&
empty_string
;
make_scrambled_password
(
tmp_value
,
res
->
c_ptr
(),
opt_old_passwords
,
&
rand_st
);
str
->
set
(
tmp_value
,
get_password_length
(
opt_old_passwords
),
res
->
charset
());
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment