Skip to content

Commit 76ae67b

Browse files
author
Kristofer Pettersson
committed
WL5602
1 parent 0e0079d commit 76ae67b

File tree

5 files changed

+21
-28
lines changed

5 files changed

+21
-28
lines changed

include/crypt_genhash_impl.h

+6-6
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ int extract_user_salt(char **salt_begin,
2020
char **salt_end);
2121
C_MODE_START
2222
char *
23-
crypt_genhash_impl(char *ctbuffer,
24-
size_t ctbufflen,
25-
const char *plaintext,
26-
int plaintext_len,
27-
const char *switchsalt,
28-
const char **params);
23+
my_crypt_genhash(char *ctbuffer,
24+
size_t ctbufflen,
25+
const char *plaintext,
26+
int plaintext_len,
27+
const char *switchsalt,
28+
const char **params);
2929
void generate_user_salt(char *buffer, int buffer_len);
3030
void xor_string(char *to, int to_len, char *pattern, int pattern_len);
3131

mysql-test/suite/sys_vars/r/all_vars.result

-4
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,5 @@ There should be *no* long test name listed below:
1010
select variable_name as `There should be *no* variables listed below:` from t2
1111
left join t1 on variable_name=test_name where test_name is null ORDER BY variable_name;
1212
There should be *no* variables listed below:
13-
SHA256_PASSWORD_PRIVATE_KEY_PATH
14-
SHA256_PASSWORD_PRIVATE_KEY_PATH
15-
SHA256_PASSWORD_PUBLIC_KEY_PATH
16-
SHA256_PASSWORD_PUBLIC_KEY_PATH
1713
drop table t1;
1814
drop table t2;

sql-common/crypt_genhash_impl.cc

+13-16
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,12 @@
66
#include <sha.hpp>
77
#include <openssl/ssl.h>
88
#else
9-
#include <sys/types.h>
109
#include <openssl/sha.h>
1110
#include <openssl/rand.h>
1211
#endif
1312

13+
#include "crypt_genhash_impl.h"
14+
1415
/* Pre VS2010 compilers doesn't support stdint.h */
1516
#ifdef HAVE_STDINT_H
1617
#include <stdint.h>
@@ -23,12 +24,10 @@ typedef unsigned char uint8_t;
2324
#endif
2425
#endif // !HAVE_STDINT_H
2526

26-
#include <errno.h>
27-
#include <string.h>
2827
#include <time.h>
29-
#include <limits.h>
28+
#include <string.h>
29+
3030

31-
#include "crypt_genhash_impl.h"
3231

3332
#ifndef HAVE_YASSL
3433
#define DIGEST_CTX SHA256_CTX
@@ -64,12 +63,6 @@ static const char crypt_alg_magic[] = "$5";
6463
#ifndef MIN
6564
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
6665
#endif
67-
#ifndef B_FALSE
68-
#define B_FALSE 0
69-
#endif
70-
#ifndef B_TRUE
71-
#define B_TRUE 1
72-
#endif
7366

7467

7568
/**
@@ -123,8 +116,6 @@ static unsigned char b64t[] = /* 0 ... 63 => ascii - 64 */
123116
#define ROUNDS "rounds="
124117
#define ROUNDSLEN (sizeof (ROUNDS) - 1)
125118

126-
typedef bool boolean_t;
127-
128119
/**
129120
Get the integer value after rounds= where ever it occurs in the string.
130121
if the last char after the int is a , or $ that is fine anything else is an
@@ -231,10 +222,16 @@ const char *sha256_find_digest(char *pass)
231222
* "Released into the Public Domain by Ulrich Drepper <drepper@redhat.com>."
232223
*/
233224

225+
/*
226+
Due to a Solaris namespace bug DS is a reserved word. To work around this
227+
DS is undefined.
228+
*/
229+
#undef DS
230+
234231
/* ARGSUSED4 */
235232
extern "C"
236233
char *
237-
crypt_genhash_impl(char *ctbuffer,
234+
my_crypt_genhash(char *ctbuffer,
238235
size_t ctbufflen,
239236
const char *plaintext,
240237
int plaintext_len,
@@ -250,7 +247,7 @@ crypt_genhash_impl(char *ctbuffer,
250247
DIGEST_CTX ctxA, ctxB, ctxC, ctxDP, ctxDS;
251248
int rounds = ROUNDS_DEFAULT;
252249
int srounds = 0;
253-
boolean_t custom_rounds = B_FALSE;
250+
bool custom_rounds= false;
254251
char *p;
255252
char *P, *Pp;
256253
char *S, *Sp;
@@ -267,7 +264,7 @@ crypt_genhash_impl(char *ctbuffer,
267264
srounds = getrounds(salt);
268265
if (srounds != 0) {
269266
rounds = MAX(ROUNDS_MIN, MIN(srounds, ROUNDS_MAX));
270-
custom_rounds = B_TRUE;
267+
custom_rounds= true;
271268
p = strchr(salt, '$');
272269
if (p != NULL)
273270
salt = p + 1;

sql/password.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ void my_make_scrambled_password(char *to, const char *password,
407407
char salt[CRYPT_SALT_LENGTH + 1];
408408

409409
generate_user_salt(salt, CRYPT_SALT_LENGTH + 1);
410-
crypt_genhash_impl(to,
410+
my_crypt_genhash(to,
411411
CRYPT_MAX_PASSWORD_SIZE,
412412
password,
413413
pass_len,

sql/sql_acl.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -11061,7 +11061,7 @@ static int sha256_password_authenticate(MYSQL_PLUGIN_VIO *vio,
1106111061
}
1106211062

1106311063
/* Create hash digest */
11064-
crypt_genhash_impl(stage2,
11064+
my_crypt_genhash(stage2,
1106511065
CRYPT_MAX_PASSWORD_SIZE,
1106611066
(char *) pkt,
1106711067
pkt_len-1,

0 commit comments

Comments
 (0)