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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
mariadb
Commits
61e08cad
Commit
61e08cad
authored
Jan 02, 2003
by
peter@mysql.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SCRUM password() function changes.
parent
dcf14ed5
Changes
1
Hide 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 @
61e08cad
...
@@ -1281,12 +1281,12 @@ String *Item_func_password::val_str(String *str)
...
@@ -1281,12 +1281,12 @@ String *Item_func_password::val_str(String *str)
struct
rand_struct
rand_st
;
// local structure for 2 param version
struct
rand_struct
rand_st
;
// local structure for 2 param version
ulong
seed
=
0
;
// seed to initialise random generator to
ulong
seed
=
0
;
// seed to initialise random generator to
String
*
res
=
args
[
0
]
->
val_str
(
str
);
if
((
null_value
=
args
[
0
]
->
null_value
))
if
((
null_value
=
args
[
0
]
->
null_value
))
return
0
;
return
0
;
if
(
arg_count
==
1
)
if
(
arg_count
==
1
)
{
{
String
*
res
=
args
[
0
]
->
val_str
(
str
);
if
(
res
->
length
()
==
0
)
if
(
res
->
length
()
==
0
)
return
&
empty_string
;
return
&
empty_string
;
make_scrambled_password
(
tmp_value
,
res
->
c_ptr
(),
opt_old_passwords
,
make_scrambled_password
(
tmp_value
,
res
->
c_ptr
(),
opt_old_passwords
,
...
@@ -1296,22 +1296,30 @@ String *Item_func_password::val_str(String *str)
...
@@ -1296,22 +1296,30 @@ String *Item_func_password::val_str(String *str)
}
}
else
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 */
/* Check second argument for NULL value. First one is already checked */
if
((
null_value
=
args
[
1
]
->
null_value
))
if
((
null_value
=
args
[
1
]
->
null_value
))
return
0
;
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 */
/* 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
)
while
(
*
seed_ptr
)
{
{
seed
=
seed
*
211
+*
seed_ptr
;
/* Use simple hashing */
seed
=
seed
*
211
+*
seed_ptr
;
/* Use simple hashing */
seed_ptr
++
;
seed_ptr
++
;
}
}
/* Use constants which allow nice random values even with small seed */
/* Use constants which allow nice random values even with small seed */
randominit
(
&
rand_st
,
seed
*
111111
+
33333333L
,
seed
*
1111
+
55555555L
);
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
,
make_scrambled_password
(
tmp_value
,
res
->
c_ptr
(),
opt_old_passwords
,
&
rand_st
);
&
rand_st
);
str
->
set
(
tmp_value
,
get_password_length
(
opt_old_passwords
),
res
->
charset
());
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