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
46ec0c5d
Commit
46ec0c5d
authored
Jan 18, 2003
by
monty@mashka.mysql.fi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Removed compiler warnings
parent
88cd4126
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
22 deletions
+26
-22
client/insert_test.c
client/insert_test.c
+1
-0
libmysql/libmysql.c
libmysql/libmysql.c
+17
-14
sql/password.c
sql/password.c
+8
-8
No files found.
client/insert_test.c
View file @
46ec0c5d
...
@@ -34,6 +34,7 @@ int main(int argc, char **argv)
...
@@ -34,6 +34,7 @@ int main(int argc, char **argv)
exit
(
1
);
exit
(
1
);
}
}
mysql_init
(
&
mysql
);
if
(
!
(
sock
=
mysql_real_connect
(
&
mysql
,
NULL
,
NULL
,
NULL
,
argv
[
1
],
0
,
NULL
,
0
)))
if
(
!
(
sock
=
mysql_real_connect
(
&
mysql
,
NULL
,
NULL
,
NULL
,
argv
[
1
],
0
,
NULL
,
0
)))
{
{
fprintf
(
stderr
,
"Couldn't connect to engine!
\n
%s
\n
"
,
mysql_error
(
&
mysql
));
fprintf
(
stderr
,
"Couldn't connect to engine!
\n
%s
\n
"
,
mysql_error
(
&
mysql
));
...
...
libmysql/libmysql.c
View file @
46ec0c5d
...
@@ -2317,10 +2317,10 @@ Try also with PIPE or TCP/IP
...
@@ -2317,10 +2317,10 @@ Try also with PIPE or TCP/IP
/* Store copy as we'll need it later */
/* Store copy as we'll need it later */
memcpy
(
password_hash
,
buff
,
SCRAMBLE41_LENGTH
);
memcpy
(
password_hash
,
buff
,
SCRAMBLE41_LENGTH
);
/* Finally hash complete password using hash we got from server */
/* Finally hash complete password using hash we got from server */
password_hash_stage2
(
password_hash
,
net
->
read_pos
);
password_hash_stage2
(
password_hash
,
(
const
char
*
)
net
->
read_pos
);
/* Decypt and store scramble 4 = hash for stage2 */
/* Decypt and store scramble 4 = hash for stage2 */
password_crypt
(
net
->
read_pos
+
4
,
mysql
->
scramble_buff
,
password_hash
,
password_crypt
(
(
const
char
*
)
net
->
read_pos
+
4
,
mysql
->
scramble_buff
,
SCRAMBLE41_LENGTH
);
password_hash
,
SCRAMBLE41_LENGTH
);
mysql
->
scramble_buff
[
SCRAMBLE41_LENGTH
]
=
0
;
mysql
->
scramble_buff
[
SCRAMBLE41_LENGTH
]
=
0
;
/* Encode scramble with password. Recycle buffer */
/* Encode scramble with password. Recycle buffer */
password_crypt
(
mysql
->
scramble_buff
,
buff
,
buff
,
SCRAMBLE41_LENGTH
);
password_crypt
(
mysql
->
scramble_buff
,
buff
,
buff
,
SCRAMBLE41_LENGTH
);
...
@@ -2534,10 +2534,10 @@ my_bool STDCALL mysql_change_user(MYSQL *mysql, const char *user,
...
@@ -2534,10 +2534,10 @@ my_bool STDCALL mysql_change_user(MYSQL *mysql, const char *user,
/* Store copy as we'll need it later */
/* Store copy as we'll need it later */
memcpy
(
password_hash
,
buff
,
SCRAMBLE41_LENGTH
);
memcpy
(
password_hash
,
buff
,
SCRAMBLE41_LENGTH
);
/* Finally hash complete password using hash we got from server */
/* Finally hash complete password using hash we got from server */
password_hash_stage2
(
password_hash
,
net
->
read_pos
);
password_hash_stage2
(
password_hash
,
(
const
char
*
)
net
->
read_pos
);
/* Decypt and store scramble 4 = hash for stage2 */
/* Decypt and store scramble 4 = hash for stage2 */
password_crypt
(
net
->
read_pos
+
4
,
mysql
->
scramble_buff
,
password_hash
,
password_crypt
(
(
const
char
*
)
net
->
read_pos
+
4
,
mysql
->
scramble_buff
,
SCRAMBLE41_LENGTH
);
password_hash
,
SCRAMBLE41_LENGTH
);
mysql
->
scramble_buff
[
SCRAMBLE41_LENGTH
]
=
0
;
mysql
->
scramble_buff
[
SCRAMBLE41_LENGTH
]
=
0
;
/* Encode scramble with password. Recycle buffer */
/* Encode scramble with password. Recycle buffer */
password_crypt
(
mysql
->
scramble_buff
,
buff
,
buff
,
SCRAMBLE41_LENGTH
);
password_crypt
(
mysql
->
scramble_buff
,
buff
,
buff
,
SCRAMBLE41_LENGTH
);
...
@@ -2547,8 +2547,8 @@ my_bool STDCALL mysql_change_user(MYSQL *mysql, const char *user,
...
@@ -2547,8 +2547,8 @@ my_bool STDCALL mysql_change_user(MYSQL *mysql, const char *user,
/* Create password to decode scramble */
/* Create password to decode scramble */
create_key_from_old_password
(
passwd
,
password_hash
);
create_key_from_old_password
(
passwd
,
password_hash
);
/* Decypt and store scramble 4 = hash for stage2 */
/* Decypt and store scramble 4 = hash for stage2 */
password_crypt
(
net
->
read_pos
+
4
,
mysql
->
scramble_buff
,
password_hash
,
password_crypt
(
(
const
char
*
)
net
->
read_pos
+
4
,
mysql
->
scramble_buff
,
SCRAMBLE41_LENGTH
);
password_hash
,
SCRAMBLE41_LENGTH
);
mysql
->
scramble_buff
[
SCRAMBLE41_LENGTH
]
=
0
;
mysql
->
scramble_buff
[
SCRAMBLE41_LENGTH
]
=
0
;
/* Finally scramble decoded scramble with password */
/* Finally scramble decoded scramble with password */
scramble
(
buff
,
mysql
->
scramble_buff
,
passwd
,
scramble
(
buff
,
mysql
->
scramble_buff
,
passwd
,
...
@@ -4059,7 +4059,7 @@ static void store_param_str(NET *net, MYSQL_BIND *param)
...
@@ -4059,7 +4059,7 @@ static void store_param_str(NET *net, MYSQL_BIND *param)
ulong
length
=
*
param
->
length
;
ulong
length
=
*
param
->
length
;
char
*
to
=
(
char
*
)
net_store_length
((
char
*
)
net
->
write_pos
,
length
);
char
*
to
=
(
char
*
)
net_store_length
((
char
*
)
net
->
write_pos
,
length
);
memcpy
(
to
,
param
->
buffer
,
length
);
memcpy
(
to
,
param
->
buffer
,
length
);
net
->
write_pos
=
to
+
length
;
net
->
write_pos
=
(
uchar
*
)
to
+
length
;
}
}
...
@@ -4211,7 +4211,7 @@ int STDCALL mysql_execute(MYSQL_STMT *stmt)
...
@@ -4211,7 +4211,7 @@ int STDCALL mysql_execute(MYSQL_STMT *stmt)
}
}
length
=
(
ulong
)
(
net
->
write_pos
-
net
->
buff
);
length
=
(
ulong
)
(
net
->
write_pos
-
net
->
buff
);
/* TODO: Look into avoding the following memdup */
/* TODO: Look into avoding the following memdup */
if
(
!
(
param_data
=
my_memdup
(
net
->
buff
,
length
,
MYF
(
0
))))
if
(
!
(
param_data
=
my_memdup
(
(
const
char
*
)
net
->
buff
,
length
,
MYF
(
0
))))
{
{
set_stmt_error
(
stmt
,
CR_OUT_OF_MEMORY
);
set_stmt_error
(
stmt
,
CR_OUT_OF_MEMORY
);
DBUG_RETURN
(
1
);
DBUG_RETURN
(
1
);
...
@@ -4538,19 +4538,22 @@ static void send_data_str(MYSQL_BIND *param, char *value, uint length)
...
@@ -4538,19 +4538,22 @@ static void send_data_str(MYSQL_BIND *param, char *value, uint length)
switch
(
param
->
buffer_type
)
{
switch
(
param
->
buffer_type
)
{
case
MYSQL_TYPE_TINY
:
case
MYSQL_TYPE_TINY
:
{
{
uchar
data
=
(
uchar
)
my_strntol
(
system_charset_info
,
value
,
length
,
10
,
NULL
,
&
err
);
uchar
data
=
(
uchar
)
my_strntol
(
system_charset_info
,
value
,
length
,
10
,
NULL
,
&
err
);
*
buffer
=
data
;
*
buffer
=
data
;
break
;
break
;
}
}
case
MYSQL_TYPE_SHORT
:
case
MYSQL_TYPE_SHORT
:
{
{
short
data
=
(
short
)
my_strntol
(
system_charset_info
,
value
,
length
,
10
,
NULL
,
&
err
);
short
data
=
(
short
)
my_strntol
(
system_charset_info
,
value
,
length
,
10
,
NULL
,
&
err
);
int2store
(
buffer
,
data
);
int2store
(
buffer
,
data
);
break
;
break
;
}
}
case
MYSQL_TYPE_LONG
:
case
MYSQL_TYPE_LONG
:
{
{
int32
data
=
(
int32
)
my_strntol
(
system_charset_info
,
value
,
length
,
10
,
NULL
,
&
err
);
int32
data
=
(
int32
)
my_strntol
(
system_charset_info
,
value
,
length
,
10
,
NULL
,
&
err
);
int4store
(
buffer
,
data
);
int4store
(
buffer
,
data
);
break
;
break
;
}
}
...
@@ -4738,7 +4741,7 @@ static my_bool fetch_results(MYSQL_STMT *stmt, MYSQL_BIND *param,
...
@@ -4738,7 +4741,7 @@ static my_bool fetch_results(MYSQL_STMT *stmt, MYSQL_BIND *param,
}
}
default:
default:
length
=
net_field_length
(
row
);
length
=
net_field_length
(
row
);
send_data_str
(
param
,
*
row
,
length
);
send_data_str
(
param
,
(
char
*
)
*
row
,
length
);
break
;
break
;
}
}
*
row
+=
length
;
*
row
+=
length
;
...
...
sql/password.c
View file @
46ec0c5d
...
@@ -236,7 +236,7 @@ void password_hash_stage1(char *to, const char *password)
...
@@ -236,7 +236,7 @@ void password_hash_stage1(char *to, const char *password)
{
{
if
(
*
password
==
' '
||
*
password
==
'\t'
)
if
(
*
password
==
' '
||
*
password
==
'\t'
)
continue
;
/* skip space in password */
continue
;
/* skip space in password */
sha1_input
(
&
context
,(
int8
*
)
&
password
[
0
],
1
);
sha1_input
(
&
context
,(
uint8
*
)
&
password
[
0
],
1
);
}
}
sha1_result
(
&
context
,(
uint8
*
)
to
);
sha1_result
(
&
context
,(
uint8
*
)
to
);
}
}
...
@@ -259,9 +259,9 @@ void password_hash_stage2(char *to,const char *salt)
...
@@ -259,9 +259,9 @@ void password_hash_stage2(char *to,const char *salt)
{
{
SHA1_CONTEXT
context
;
SHA1_CONTEXT
context
;
sha1_reset
(
&
context
);
sha1_reset
(
&
context
);
sha1_input
(
&
context
,(
uint8
*
)
salt
,
4
);
sha1_input
(
&
context
,(
uint8
*
)
salt
,
4
);
sha1_input
(
&
context
,
to
,
SHA1_HASH_SIZE
);
sha1_input
(
&
context
,
(
uint8
*
)
to
,
SHA1_HASH_SIZE
);
sha1_result
(
&
context
,(
uint8
*
)
to
);
sha1_result
(
&
context
,(
uint8
*
)
to
);
}
}
...
@@ -295,14 +295,14 @@ void make_scrambled_password(char *to,const char *password,
...
@@ -295,14 +295,14 @@ void make_scrambled_password(char *to,const char *password,
else
/* New password 4.1 password scrambling */
else
/* New password 4.1 password scrambling */
{
{
to
[
0
]
=
PVERSION41_CHAR
;
/* New passwords have version prefix */
to
[
0
]
=
PVERSION41_CHAR
;
/* New passwords have version prefix */
/* R
andom
returns number from 0 to 1 so this would be good salt generation.*/
/* R
nd
returns number from 0 to 1 so this would be good salt generation.*/
salt
=
rnd
(
rand_st
)
*
65535
+
1
;
salt
=
rnd
(
rand_st
)
*
65535
+
1
;
/* Use only 2 first bytes from it */
/* Use only 2 first bytes from it */
sprintf
(
to
+
1
,
"%04x"
,
salt
);
sprintf
(
to
+
1
,
"%04x"
,
salt
);
/* First hasing is done without salt */
/* First hasing is done without salt */
password_hash_stage1
(
digest
,
password
);
password_hash_stage1
(
(
char
*
)
digest
,
password
);
/* Second stage is done with salt */
/* Second stage is done with salt */
password_hash_stage2
(
digest
,(
char
*
)
to
+
1
),
password_hash_stage2
(
(
char
*
)
digest
,(
char
*
)
to
+
1
),
/* Print resulting hash into the password*/
/* Print resulting hash into the password*/
sprintf
(
to
+
5
,
sprintf
(
to
+
5
,
"%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x"
,
"%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x"
,
...
@@ -376,7 +376,7 @@ my_bool validate_password(const char* password, const char* message,
...
@@ -376,7 +376,7 @@ my_bool validate_password(const char* password, const char* message,
password_hash_stage2
(
buffer
,
tmpsalt
);
password_hash_stage2
(
buffer
,
tmpsalt
);
/* Convert password to salt to compare */
/* Convert password to salt to compare */
get_salt_from_bin_password
(
salt_candidate
,
buffer
,
salt
[
0
]);
get_salt_from_bin_password
(
salt_candidate
,
(
uchar
*
)
buffer
,
salt
[
0
]);
/* Now we shall get exactly the same password as we have stored for user */
/* Now we shall get exactly the same password as we have stored for user */
for
(
salt_end
=
salt
+
5
;
salt
<
salt_end
;
)
for
(
salt_end
=
salt
+
5
;
salt
<
salt_end
;
)
...
...
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