diff options
author | Patrick Griffis <tingping@tingping.se> | 2016-04-13 18:46:20 -0400 |
---|---|---|
committer | Patrick Griffis <tingping@tingping.se> | 2016-04-13 18:47:51 -0400 |
commit | 44aa999598af1e798321d595372dac84eaf8a2ba (patch) | |
tree | 6ca8df391d0a8e516263616bb0cbbfeec4cc1fd7 /src/common/util.c | |
parent | 54c6418d619e1ec96166f9fabb426f011068de99 (diff) |
Fix challengeauth lower casing username
Diffstat (limited to 'src/common/util.c')
-rw-r--r-- | src/common/util.c | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/src/common/util.c b/src/common/util.c index 5c4eb8bf..490c3cd2 100644 --- a/src/common/util.c +++ b/src/common/util.c @@ -1414,6 +1414,21 @@ str_sha256hash (char *string) return g_strdup (buf); } +static char * +rfc_strlower (const char *str) +{ + size_t i, len = strlen(str); + char *lower = g_new(char, len + 1); + + for (i = 0; i < len; ++i) + { + lower[i] = rfc_tolower(str[i]); + } + lower[i] = '\0'; + + return lower; +} + /** * \brief Generate CHALLENGEAUTH response for QuakeNet login. * @@ -1430,7 +1445,7 @@ str_sha256hash (char *string) * <a href="http://stackoverflow.com/questions/242665/understanding-engine-initialization-in-openssl">example 2</a>. */ char * -challengeauth_response (char *username, char *password, char *challenge) +challengeauth_response (const char *username, const char *password, const char *challenge) { int i; char *user; @@ -1441,8 +1456,7 @@ challengeauth_response (char *username, char *password, char *challenge) unsigned char *digest; GString *buf = g_string_new_len (NULL, SHA256_DIGEST_LENGTH * 2); - user = g_strdup (username); - *user = rfc_tolower (*username); /* convert username to lowercase as per the RFC */ + user = rfc_strlower (username); /* convert username to lowercase as per the RFC */ pass = g_strndup (password, 10); /* truncate to 10 characters */ passhash = str_sha256hash (pass); |