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
0fa2fdb9
Commit
0fa2fdb9
authored
Jan 12, 2006
by
unknown
Browse files
Options
Browse Files
Download
Plain Diff
Merge bk-internal.mysql.com:/home/bk/mysql-4.1
into mysql.com:/home/my/mysql-4.1
parents
af024409
f00e5b36
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
60 additions
and
40 deletions
+60
-40
include/sha1.h
include/sha1.h
+3
-3
mysql-test/r/ctype_utf8.result
mysql-test/r/ctype_utf8.result
+8
-0
mysql-test/t/ctype_utf8.test
mysql-test/t/ctype_utf8.test
+10
-0
mysys/sha1.c
mysys/sha1.c
+8
-8
sql/field.cc
sql/field.cc
+3
-3
sql/item_strfunc.cc
sql/item_strfunc.cc
+5
-3
sql/password.c
sql/password.c
+23
-23
No files found.
include/sha1.h
View file @
0fa2fdb9
...
@@ -60,8 +60,8 @@ typedef struct SHA1_CONTEXT
...
@@ -60,8 +60,8 @@ typedef struct SHA1_CONTEXT
C_MODE_START
C_MODE_START
int
sha1_reset
(
SHA1_CONTEXT
*
);
int
mysql_sha1_reset
(
SHA1_CONTEXT
*
);
int
sha1_input
(
SHA1_CONTEXT
*
,
const
uint8
*
,
unsigned
int
);
int
mysql_sha1_input
(
SHA1_CONTEXT
*
,
const
uint8
*
,
unsigned
int
);
int
sha1_result
(
SHA1_CONTEXT
*
,
uint8
Message_Digest
[
SHA1_HASH_SIZE
]
);
int
mysql_sha1_result
(
SHA1_CONTEXT
*
,
uint8
Message_Digest
[
SHA1_HASH_SIZE
]
);
C_MODE_END
C_MODE_END
mysql-test/r/ctype_utf8.result
View file @
0fa2fdb9
...
@@ -1070,3 +1070,11 @@ char(a)
...
@@ -1070,3 +1070,11 @@ char(a)
1
1
2
2
drop table t1;
drop table t1;
CREATE TABLE t1 (t TINYTEXT CHARACTER SET utf8);
INSERT INTO t1 VALUES(REPEAT('a', 100));
CREATE TEMPORARY TABLE t2 SELECT COALESCE(t) AS bug FROM t1;
SELECT LENGTH(bug) FROM t2;
LENGTH(bug)
100
DROP TABLE t2;
DROP TABLE t1;
mysql-test/t/ctype_utf8.test
View file @
0fa2fdb9
...
@@ -882,4 +882,14 @@ set names utf8;
...
@@ -882,4 +882,14 @@ set names utf8;
select
distinct
char
(
a
)
from
t1
;
select
distinct
char
(
a
)
from
t1
;
drop
table
t1
;
drop
table
t1
;
#
# Bug#15581: COALESCE function truncates mutli-byte TINYTEXT values
#
CREATE
TABLE
t1
(
t
TINYTEXT
CHARACTER
SET
utf8
);
INSERT
INTO
t1
VALUES
(
REPEAT
(
'a'
,
100
));
CREATE
TEMPORARY
TABLE
t2
SELECT
COALESCE
(
t
)
AS
bug
FROM
t1
;
SELECT
LENGTH
(
bug
)
FROM
t2
;
DROP
TABLE
t2
;
DROP
TABLE
t1
;
# End of 4.1 tests
# End of 4.1 tests
mysys/sha1.c
View file @
0fa2fdb9
...
@@ -69,7 +69,7 @@ static void SHA1ProcessMessageBlock(SHA1_CONTEXT*);
...
@@ -69,7 +69,7 @@ static void SHA1ProcessMessageBlock(SHA1_CONTEXT*);
Initialize SHA1Context
Initialize SHA1Context
SYNOPSIS
SYNOPSIS
sha1_reset()
mysql_
sha1_reset()
context [in/out] The context to reset.
context [in/out] The context to reset.
DESCRIPTION
DESCRIPTION
...
@@ -92,7 +92,7 @@ const uint32 sha_const_key[5]=
...
@@ -92,7 +92,7 @@ const uint32 sha_const_key[5]=
};
};
int
sha1_reset
(
SHA1_CONTEXT
*
context
)
int
mysql_
sha1_reset
(
SHA1_CONTEXT
*
context
)
{
{
#ifndef DBUG_OFF
#ifndef DBUG_OFF
if
(
!
context
)
if
(
!
context
)
...
@@ -119,7 +119,7 @@ int sha1_reset(SHA1_CONTEXT *context)
...
@@ -119,7 +119,7 @@ int sha1_reset(SHA1_CONTEXT *context)
Return the 160-bit message digest into the array provided by the caller
Return the 160-bit message digest into the array provided by the caller
SYNOPSIS
SYNOPSIS
sha1_result()
mysql_
sha1_result()
context [in/out] The context to use to calculate the SHA-1 hash.
context [in/out] The context to use to calculate the SHA-1 hash.
Message_Digest: [out] Where the digest is returned.
Message_Digest: [out] Where the digest is returned.
...
@@ -132,7 +132,7 @@ int sha1_reset(SHA1_CONTEXT *context)
...
@@ -132,7 +132,7 @@ int sha1_reset(SHA1_CONTEXT *context)
!= SHA_SUCCESS sha Error Code.
!= SHA_SUCCESS sha Error Code.
*/
*/
int
sha1_result
(
SHA1_CONTEXT
*
context
,
int
mysql_
sha1_result
(
SHA1_CONTEXT
*
context
,
uint8
Message_Digest
[
SHA1_HASH_SIZE
])
uint8
Message_Digest
[
SHA1_HASH_SIZE
])
{
{
int
i
;
int
i
;
...
@@ -165,7 +165,7 @@ int sha1_result(SHA1_CONTEXT *context,
...
@@ -165,7 +165,7 @@ int sha1_result(SHA1_CONTEXT *context,
Accepts an array of octets as the next portion of the message.
Accepts an array of octets as the next portion of the message.
SYNOPSIS
SYNOPSIS
sha1_input()
mysql_
sha1_input()
context [in/out] The SHA context to update
context [in/out] The SHA context to update
message_array An array of characters representing the next portion
message_array An array of characters representing the next portion
of the message.
of the message.
...
@@ -176,7 +176,7 @@ int sha1_result(SHA1_CONTEXT *context,
...
@@ -176,7 +176,7 @@ int sha1_result(SHA1_CONTEXT *context,
!= SHA_SUCCESS sha Error Code.
!= SHA_SUCCESS sha Error Code.
*/
*/
int
sha1_input
(
SHA1_CONTEXT
*
context
,
const
uint8
*
message_array
,
int
mysql_
sha1_input
(
SHA1_CONTEXT
*
context
,
const
uint8
*
message_array
,
unsigned
length
)
unsigned
length
)
{
{
if
(
!
length
)
if
(
!
length
)
...
...
sql/field.cc
View file @
0fa2fdb9
...
@@ -6949,11 +6949,11 @@ uint32 Field_blob::max_length()
...
@@ -6949,11 +6949,11 @@ uint32 Field_blob::max_length()
switch
(
packlength
)
switch
(
packlength
)
{
{
case
1
:
case
1
:
return
255
;
return
255
*
field_charset
->
mbmaxlen
;
case
2
:
case
2
:
return
65535
;
return
65535
*
field_charset
->
mbmaxlen
;
case
3
:
case
3
:
return
16777215
;
return
16777215
*
field_charset
->
mbmaxlen
;
case
4
:
case
4
:
return
(
uint32
)
4294967295U
;
return
(
uint32
)
4294967295U
;
default:
default:
...
...
sql/item_strfunc.cc
View file @
0fa2fdb9
...
@@ -131,11 +131,13 @@ String *Item_func_sha::val_str(String *str)
...
@@ -131,11 +131,13 @@ String *Item_func_sha::val_str(String *str)
SHA1_CONTEXT
context
;
/* Context used to generate SHA1 hash */
SHA1_CONTEXT
context
;
/* Context used to generate SHA1 hash */
/* Temporary buffer to store 160bit digest */
/* Temporary buffer to store 160bit digest */
uint8
digest
[
SHA1_HASH_SIZE
];
uint8
digest
[
SHA1_HASH_SIZE
];
sha1_reset
(
&
context
);
/* We do not have to check for error here */
mysql_
sha1_reset
(
&
context
);
/* We do not have to check for error here */
/* No need to check error as the only case would be too long message */
/* No need to check error as the only case would be too long message */
sha1_input
(
&
context
,(
const
unsigned
char
*
)
sptr
->
ptr
(),
sptr
->
length
());
mysql_sha1_input
(
&
context
,
(
const
unsigned
char
*
)
sptr
->
ptr
(),
sptr
->
length
());
/* Ensure that memory is free and we got result */
/* Ensure that memory is free and we got result */
if
(
!
(
str
->
alloc
(
SHA1_HASH_SIZE
*
2
)
||
(
sha1_result
(
&
context
,
digest
))))
if
(
!
(
str
->
alloc
(
SHA1_HASH_SIZE
*
2
)
||
(
mysql_sha1_result
(
&
context
,
digest
))))
{
{
sprintf
((
char
*
)
str
->
ptr
(),
sprintf
((
char
*
)
str
->
ptr
(),
"%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x\
"%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x\
...
...
sql/password.c
View file @
0fa2fdb9
...
@@ -392,15 +392,15 @@ make_scrambled_password(char *to, const char *password)
...
@@ -392,15 +392,15 @@ make_scrambled_password(char *to, const char *password)
SHA1_CONTEXT
sha1_context
;
SHA1_CONTEXT
sha1_context
;
uint8
hash_stage2
[
SHA1_HASH_SIZE
];
uint8
hash_stage2
[
SHA1_HASH_SIZE
];
sha1_reset
(
&
sha1_context
);
mysql_
sha1_reset
(
&
sha1_context
);
/* stage 1: hash password */
/* stage 1: hash password */
sha1_input
(
&
sha1_context
,
(
uint8
*
)
password
,
strlen
(
password
));
mysql_
sha1_input
(
&
sha1_context
,
(
uint8
*
)
password
,
strlen
(
password
));
sha1_result
(
&
sha1_context
,
(
uint8
*
)
to
);
mysql_
sha1_result
(
&
sha1_context
,
(
uint8
*
)
to
);
/* stage 2: hash stage1 output */
/* stage 2: hash stage1 output */
sha1_reset
(
&
sha1_context
);
mysql_
sha1_reset
(
&
sha1_context
);
sha1_input
(
&
sha1_context
,
(
uint8
*
)
to
,
SHA1_HASH_SIZE
);
mysql_
sha1_input
(
&
sha1_context
,
(
uint8
*
)
to
,
SHA1_HASH_SIZE
);
/* separate buffer is used to pass 'to' in octet2hex */
/* separate buffer is used to pass 'to' in octet2hex */
sha1_result
(
&
sha1_context
,
hash_stage2
);
mysql_
sha1_result
(
&
sha1_context
,
hash_stage2
);
/* convert hash_stage2 to hex string */
/* convert hash_stage2 to hex string */
*
to
++=
PVERSION41_CHAR
;
*
to
++=
PVERSION41_CHAR
;
octet2hex
(
to
,
hash_stage2
,
SHA1_HASH_SIZE
);
octet2hex
(
to
,
hash_stage2
,
SHA1_HASH_SIZE
);
...
@@ -431,20 +431,20 @@ scramble(char *to, const char *message, const char *password)
...
@@ -431,20 +431,20 @@ scramble(char *to, const char *message, const char *password)
uint8
hash_stage1
[
SHA1_HASH_SIZE
];
uint8
hash_stage1
[
SHA1_HASH_SIZE
];
uint8
hash_stage2
[
SHA1_HASH_SIZE
];
uint8
hash_stage2
[
SHA1_HASH_SIZE
];
sha1_reset
(
&
sha1_context
);
mysql_
sha1_reset
(
&
sha1_context
);
/* stage 1: hash password */
/* stage 1: hash password */
sha1_input
(
&
sha1_context
,
(
uint8
*
)
password
,
strlen
(
password
));
mysql_
sha1_input
(
&
sha1_context
,
(
uint8
*
)
password
,
strlen
(
password
));
sha1_result
(
&
sha1_context
,
hash_stage1
);
mysql_
sha1_result
(
&
sha1_context
,
hash_stage1
);
/* stage 2: hash stage 1; note that hash_stage2 is stored in the database */
/* stage 2: hash stage 1; note that hash_stage2 is stored in the database */
sha1_reset
(
&
sha1_context
);
mysql_
sha1_reset
(
&
sha1_context
);
sha1_input
(
&
sha1_context
,
hash_stage1
,
SHA1_HASH_SIZE
);
mysql_
sha1_input
(
&
sha1_context
,
hash_stage1
,
SHA1_HASH_SIZE
);
sha1_result
(
&
sha1_context
,
hash_stage2
);
mysql_
sha1_result
(
&
sha1_context
,
hash_stage2
);
/* create crypt string as sha1(message, hash_stage2) */
;
/* create crypt string as sha1(message, hash_stage2) */
;
sha1_reset
(
&
sha1_context
);
mysql_
sha1_reset
(
&
sha1_context
);
sha1_input
(
&
sha1_context
,
(
const
uint8
*
)
message
,
SCRAMBLE_LENGTH
);
mysql_
sha1_input
(
&
sha1_context
,
(
const
uint8
*
)
message
,
SCRAMBLE_LENGTH
);
sha1_input
(
&
sha1_context
,
hash_stage2
,
SHA1_HASH_SIZE
);
mysql_
sha1_input
(
&
sha1_context
,
hash_stage2
,
SHA1_HASH_SIZE
);
/* xor allows 'from' and 'to' overlap: lets take advantage of it */
/* xor allows 'from' and 'to' overlap: lets take advantage of it */
sha1_result
(
&
sha1_context
,
(
uint8
*
)
to
);
mysql_
sha1_result
(
&
sha1_context
,
(
uint8
*
)
to
);
my_crypt
(
to
,
(
const
uchar
*
)
to
,
hash_stage1
,
SCRAMBLE_LENGTH
);
my_crypt
(
to
,
(
const
uchar
*
)
to
,
hash_stage1
,
SCRAMBLE_LENGTH
);
}
}
...
@@ -477,17 +477,17 @@ check_scramble(const char *scramble, const char *message,
...
@@ -477,17 +477,17 @@ check_scramble(const char *scramble, const char *message,
uint8
buf
[
SHA1_HASH_SIZE
];
uint8
buf
[
SHA1_HASH_SIZE
];
uint8
hash_stage2_reassured
[
SHA1_HASH_SIZE
];
uint8
hash_stage2_reassured
[
SHA1_HASH_SIZE
];
sha1_reset
(
&
sha1_context
);
mysql_
sha1_reset
(
&
sha1_context
);
/* create key to encrypt scramble */
/* create key to encrypt scramble */
sha1_input
(
&
sha1_context
,
(
const
uint8
*
)
message
,
SCRAMBLE_LENGTH
);
mysql_
sha1_input
(
&
sha1_context
,
(
const
uint8
*
)
message
,
SCRAMBLE_LENGTH
);
sha1_input
(
&
sha1_context
,
hash_stage2
,
SHA1_HASH_SIZE
);
mysql_
sha1_input
(
&
sha1_context
,
hash_stage2
,
SHA1_HASH_SIZE
);
sha1_result
(
&
sha1_context
,
buf
);
mysql_
sha1_result
(
&
sha1_context
,
buf
);
/* encrypt scramble */
/* encrypt scramble */
my_crypt
((
char
*
)
buf
,
buf
,
(
const
uchar
*
)
scramble
,
SCRAMBLE_LENGTH
);
my_crypt
((
char
*
)
buf
,
buf
,
(
const
uchar
*
)
scramble
,
SCRAMBLE_LENGTH
);
/* now buf supposedly contains hash_stage1: so we can get hash_stage2 */
/* now buf supposedly contains hash_stage1: so we can get hash_stage2 */
sha1_reset
(
&
sha1_context
);
mysql_
sha1_reset
(
&
sha1_context
);
sha1_input
(
&
sha1_context
,
buf
,
SHA1_HASH_SIZE
);
mysql_
sha1_input
(
&
sha1_context
,
buf
,
SHA1_HASH_SIZE
);
sha1_result
(
&
sha1_context
,
hash_stage2_reassured
);
mysql_
sha1_result
(
&
sha1_context
,
hash_stage2_reassured
);
return
memcmp
(
hash_stage2
,
hash_stage2_reassured
,
SHA1_HASH_SIZE
);
return
memcmp
(
hash_stage2
,
hash_stage2_reassured
,
SHA1_HASH_SIZE
);
}
}
...
...
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