summaryrefslogtreecommitdiff
path: root/sql/password.c
diff options
context:
space:
mode:
authorunknown <monty@mashka.mysql.fi>2003-02-12 21:55:37 +0200
committerunknown <monty@mashka.mysql.fi>2003-02-12 21:55:37 +0200
commitfcb61f5917ee69bba91bd6a926db2eab4ac3eeb5 (patch)
tree3ac37e452f15c8f05e9d1f338a6050281f838048 /sql/password.c
parent363fd89b92de2fc58e7910f7a27684308656ebda (diff)
downloadmariadb-git-fcb61f5917ee69bba91bd6a926db2eab4ac3eeb5.tar.gz
Fixed a lot of wrong memory references as reported by valgrind
Portability fixes Added new client function: mysql_get_server_version() New server help code (From Victor Vagin) Fixed wrong usage of binary() Disabled RTREE usage for now. BitKeeper/etc/ignore: added scripts/fill_help_tables.sql client/mysql.cc: Some fixes when using 'help' cmd-line-utils/libedit/compat.h: Portability fix cmd-line-utils/libedit/fgetln.c: Portability fix include/mysql.h: Added new client function: mysql_get_server_version() libmysql/libmysql.c: Added new client function: mysql_get_server_version() libmysqld/libmysqld.c: Fixed prototype mysql-test/install_test_db.sh: Added creation of help tables mysql-test/r/connect.result: Added help tables mysql-test/r/myisam.result: Test of RTREE index mysql-test/r/type_ranges.result: updated results mysql-test/t/myisam.test: Test of RTREE index mysql-test/t/type_ranges.test: Updated test mysys/charset.c: Indentation change mysys/my_symlink.c: Removed compiler warning scripts/fill_help_tables.sh: Update for new help tables sql/field.cc: Indentation changes sql/filesort.cc: Optimized character set usage sql/item_cmpfunc.cc: Fix wrong usage of binary() sql/item_cmpfunc.h: Fix wrong usage of binary() sql/item_func.cc: Fix wrong usage of binary() sql/item_func.h: Fix wrong usage of binary() sql/item_strfunc.cc: Fix wrong usage of binary() sql/item_sum.cc: Fix wrong usage of binary() sql/item_sum.h: Fix wrong usage of binary() sql/key.cc: Indentation change sql/lex.h: HELP -> HELP_SYM sql/mysql_priv.h: Make get_field() more general sql/password.c: Indentation change + variable initialisation moved sql/sql_acl.cc: Make get_field() more general sql/sql_base.cc: Added comments + assertion for double call to mysql_lock_tables sql/sql_cache.cc: Indentation changes sql/sql_class.h: Added need_strxnfrm to SORT_FIELD to be able to optimise character set handling in filesort sql/sql_derived.cc: Renamed variables sql/sql_help.cc: New help functions (from Victor Vagin) sql/sql_lex.cc: Removed variables that doesn't have to be initialized for each query sql/sql_lex.h: Removed not used variable (olap) sql/sql_parse.cc: Fixed (not fatal) access of unitialized memory Indentation / code cleanup sql/sql_prepare.cc: Indentaion cleanup sql/sql_table.cc: Disabled RTREE until 5.0 sql/sql_udf.cc: Make get_field() more general sql/sql_yacc.yy: Removed access to uninitialized memory Always set offset_limit and select_limit when using LIMIT (removed warnings) Allow usage of 'help week' sql/table.cc: Make get_field() more general More comments sql/table.h: Fixded type of TABLE_LIST->derived sql/time.cc: Stricter date / datetime handling (to be able to handle timestamps with days and microseconds) strings/ctype-bin.c: Added cha
Diffstat (limited to 'sql/password.c')
-rw-r--r--sql/password.c47
1 files changed, 24 insertions, 23 deletions
diff --git a/sql/password.c b/sql/password.c
index 37040c20683..5ed05ae6c0e 100644
--- a/sql/password.c
+++ b/sql/password.c
@@ -147,9 +147,9 @@ double rnd(struct rand_struct *rand_st)
none
*/
-void create_random_string(int length,struct rand_struct *rand_st,char* target)
+void create_random_string(int length,struct rand_struct *rand_st,char *target)
{
- char* end=target+length;
+ char *end=target+length;
/* Use pointer arithmetics as it is faster way to do so. */
for (; target<end ; target++)
*target= (char) (rnd(rand_st)*94+33);
@@ -171,7 +171,7 @@ void create_random_string(int length,struct rand_struct *rand_st,char* target)
none
*/
-void password_crypt(const char* from,char* to, const char* password,int length)
+void password_crypt(const char *from,char *to, const char *password,int length)
{
const char *from_end=from+length;
@@ -252,7 +252,7 @@ void password_hash_stage1(char *to, const char *password)
none
*/
-void password_hash_stage2(char *to,const char *salt)
+void password_hash_stage2(char *to, const char *salt)
{
SHA1_CONTEXT context;
sha1_reset(&context);
@@ -326,7 +326,7 @@ void make_scrambled_password(char *to,const char *password,
void get_salt_from_bin_password(ulong *res,unsigned char *password,ulong salt)
{
- unsigned char* password_end=password+SCRAMBLE41_LENGTH;
+ unsigned char *password_end=password+SCRAMBLE41_LENGTH;
*res=salt;
res++;
@@ -356,14 +356,14 @@ void get_salt_from_bin_password(ulong *res,unsigned char *password,ulong salt)
!0 for invalid password
*/
-my_bool validate_password(const char* password, const char* message,
- ulong* salt)
+my_bool validate_password(const char *password, const char *message,
+ ulong *salt)
{
char buffer[SCRAMBLE41_LENGTH]; /* Used for password validation */
char tmpsalt[8]; /* Temporary value to convert salt to string form */
ulong salt_candidate[6]; /* Computed candidate salt */
- ulong* sc=salt_candidate; /* we need to be able to increment */
- ulong* salt_end;
+ ulong *sc=salt_candidate; /* we need to be able to increment */
+ ulong *salt_end;
/* Now we shall get stage1 encrypted password in buffer*/
password_crypt(password,buffer,message,SCRAMBLE41_LENGTH);
@@ -414,7 +414,7 @@ int get_password_length(my_bool force_old_scramble)
!0 password version char for newer passwords
*/
-char get_password_version(const char* password)
+char get_password_version(const char *password)
{
if (password==NULL) return 0;
if (password[0]==PVERSION41_CHAR) return PVERSION41_CHAR;
@@ -536,46 +536,47 @@ void make_password_from_salt(char *to, ulong *hash_res,uint8 password_version)
!0 password version char for newer passwords
*/
-void get_hash_and_password(ulong* salt, uint8 pversion, char* hash, unsigned char* bin_password)
+void get_hash_and_password(ulong *salt, uint8 pversion, char *hash,
+ unsigned char *bin_password)
{
int t;
ulong* salt_end;
ulong val;
SHA1_CONTEXT context;
- unsigned char* bp; /* Binary password loop pointer */
- if (pversion) /* New password version assumed */
+ if (pversion) /* New password version assumed */
{
salt_end=salt+5;
sprintf(hash,"%04x",(unsigned short)salt[0]);
- while (salt<salt_end) /* Iterate over these elements*/
+ while (salt<salt_end)
{
val=*(++salt);
for (t=3; t>=0; t--)
{
bin_password[t]= (char) (val & 255);
- val>>=8; /* Scroll 8 bits to get next part*/
+ val>>=8; /* Scroll 8 bits to get next part*/
}
- bin_password+=4; /* Get to next 4 chars*/
+ bin_password+=4; /* Get to next 4 chars*/
}
}
else
{
+ unsigned char *bp= bin_password; /* Binary password loop pointer */
+
/* Use zero starting hash as an indication of old password */
hash[0]=0;
salt_end=salt+2;
- bp=bin_password;
/* Encode salt using SHA1 here */
sha1_reset(&context);
- while (salt<salt_end) /* Iterate over these elements*/
+ while (salt<salt_end) /* Iterate over these elements*/
{
- val=*salt;
+ val= *salt;
for (t=3;t>=0;t--)
{
bp[t]= (uchar) (val & 255);
- val>>=8; /* Scroll 8 bits to get next part*/
+ val>>=8; /* Scroll 8 bits to get next part*/
}
- bp+=4; /* Get to next 4 chars*/
+ bp+= 4; /* Get to next 4 chars*/
salt++;
}
/* Use 8 bytes of binary password for hash */
@@ -599,7 +600,7 @@ void get_hash_and_password(ulong* salt, uint8 pversion, char* hash, unsigned cha
*/
-void create_key_from_old_password(const char* passwd, char* key)
+void create_key_from_old_password(const char *passwd, char *key)
{
char buffer[SCRAMBLE41_LENGTH]; /* Buffer for various needs */
ulong salt[6]; /* Salt (large for safety) */
@@ -633,7 +634,7 @@ char *scramble(char *to,const char *message,const char *password,
struct rand_struct rand_st;
ulong hash_pass[2],hash_message[2];
char message_buffer[9]; /* Real message buffer */
- char* msg=message_buffer;
+ char *msg=message_buffer;
/* We use special message buffer now as new server can provide longer hash */