summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <cmiller@zippy.cornsilk.net>2007-06-12 08:47:36 -0400
committerunknown <cmiller@zippy.cornsilk.net>2007-06-12 08:47:36 -0400
commit3a364d517246d6d571a3c5eecac99dbee6dac7db (patch)
tree60ba780a8f3abdf1280e3d8ac050cbd026a7a245
parent606927f78f47f65dee56c75796cda6c1ba8aad51 (diff)
downloadmariadb-git-3a364d517246d6d571a3c5eecac99dbee6dac7db.tar.gz
Bug#28984: crasher on connect with out of range password length in \
protocol Fixed duplicated code, same as last commit. One could send a malformed packet that caused the server to SEGV. In recent versions of the password protocol, the client tells the server what length the ciphertext is (almost always 20). If that length was large enough to overflow a signed char, then the number would jump to very large after being casted to unsigned int. Instead, cast the *passwd char to uchar. sql/sql_parse.cc: Additional location of signed-char casted to uint.
-rw-r--r--sql/sql_parse.cc5
1 files changed, 4 insertions, 1 deletions
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index 4e84bc9d046..24f9ef30569 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -1445,11 +1445,14 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
Old clients send null-terminated string ('\0' for empty string) for
password. New clients send the size (1 byte) + string (not null
terminated, so also '\0' for empty string).
+
+ Cast *passwd to an unsigned char, so that it doesn't extend the sign
+ for *passwd > 127 and become 2**32-127 after casting to uint.
*/
char db_buff[NAME_LEN+1]; // buffer to store db in utf8
char *db= passwd;
uint passwd_len= thd->client_capabilities & CLIENT_SECURE_CONNECTION ?
- *passwd++ : strlen(passwd);
+ (uchar)(*passwd++) : strlen(passwd);
db+= passwd_len + 1;
#ifndef EMBEDDED_LIBRARY
/* Small check for incomming packet */