summaryrefslogtreecommitdiff
path: root/sql/password.c
diff options
context:
space:
mode:
authorKent Boortz <kent.boortz@oracle.com>2011-07-03 17:47:37 +0200
committerKent Boortz <kent.boortz@oracle.com>2011-07-03 17:47:37 +0200
commit027b5f1ed4f0130bbbc174eb45162a402c65f43f (patch)
tree448d397ed328f719a29a8fbbd54df8d943ed7274 /sql/password.c
parent68f00a56868c5ca21b2d51598e1a43969ecf4896 (diff)
parentdd4957965411c1b67ebfb1ba8650a3090d305f63 (diff)
downloadmariadb-git-027b5f1ed4f0130bbbc174eb45162a402c65f43f.tar.gz
Updated/added copyright headers
Diffstat (limited to 'sql/password.c')
-rw-r--r--sql/password.c35
1 files changed, 18 insertions, 17 deletions
diff --git a/sql/password.c b/sql/password.c
index 6bf39f53d86..e9e81fb7bf3 100644
--- a/sql/password.c
+++ b/sql/password.c
@@ -1,6 +1,5 @@
/*
- Copyright (c) 2000-2006 MySQL AB, 2009 Sun Microsystems, Inc.
- Use is subject to license terms.
+ Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -207,21 +206,16 @@ void scramble_323(char *to, const char *message, const char *password)
}
-/*
- Check scrambled message
- Used in pre 4.1 password handling
- SYNOPSIS
- check_scramble_323()
- scrambled scrambled message to check.
- message original random message which was used for scrambling; must
- be exactly SCRAMBLED_LENGTH_323 bytes long and
- NULL-terminated.
- hash_pass password which should be used for scrambling
- All params are IN.
+/**
+ Check scrambled message. Used in pre 4.1 password handling.
- RETURN VALUE
- 0 - password correct
- !0 - password invalid
+ @param scrambled Scrambled message to check.
+ @param message Original random message which was used for scrambling.
+ @param hash_pass Password which should be used for scrambling.
+
+ @remark scrambled and message must be SCRAMBLED_LENGTH_323 bytes long.
+
+ @return FALSE if password is correct, TRUE otherwise.
*/
my_bool
@@ -230,9 +224,16 @@ check_scramble_323(const char *scrambled, const char *message,
{
struct rand_struct rand_st;
ulong hash_message[2];
- char buff[16],*to,extra; /* Big enough for check */
+ /* Big enough for checks. */
+ char buff[16], scrambled_buff[SCRAMBLE_LENGTH_323 + 1];
+ char *to, extra;
const char *pos;
+ /* Ensure that the scrambled message is null-terminated. */
+ memcpy(scrambled_buff, scrambled, SCRAMBLE_LENGTH_323);
+ scrambled_buff[SCRAMBLE_LENGTH_323]= '\0';
+ scrambled= scrambled_buff;
+
hash_password(hash_message, message, SCRAMBLE_LENGTH_323);
randominit(&rand_st,hash_pass[0] ^ hash_message[0],
hash_pass[1] ^ hash_message[1]);