Skip to content

Commit f4165ea

Browse files
harinvadodariaprashanttekriwal
authored andcommitted
Bug#25714674: MYSQL SERVER REMOTE PREAUTH PROBLEM THROUGH INTEGER OVERFLOW
Description: A missing length check for length-encoded string causes problem in preauthorization stage. (cherry picked from commit bb1af908fce21b0d8708cdccde628e3d5b1d86ec)
1 parent d4ebd82 commit f4165ea

File tree

1 file changed

+30
-1
lines changed

1 file changed

+30
-1
lines changed

sql/sql_acl.cc

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
1+
/* Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
22
sql_authenticate
33
This program is free software; you can redistribute it and/or modify
44
it under the terms of the GNU General Public License as published by
@@ -10739,6 +10739,9 @@ char *get_56_lenc_string(char **buffer,
1073910739
{
1074010740
static char empty_string[1]= { '\0' };
1074110741
char *begin= *buffer;
10742+
uchar *pos= (uchar *)begin;
10743+
size_t required_length= 9;
10744+
1074210745

1074310746
if (*max_bytes_available == 0)
1074410747
return NULL;
@@ -10759,13 +10762,39 @@ char *get_56_lenc_string(char **buffer,
1075910762
return empty_string;
1076010763
}
1076110764

10765+
/* Make sure we have enough bytes available for net_field_length_ll */
10766+
{
10767+
DBUG_EXECUTE_IF("buffer_too_short_3",
10768+
*pos= 252; *max_bytes_available= 2;
10769+
);
10770+
DBUG_EXECUTE_IF("buffer_too_short_4",
10771+
*pos= 253; *max_bytes_available= 3;
10772+
);
10773+
DBUG_EXECUTE_IF("buffer_too_short_9",
10774+
*pos= 254; *max_bytes_available= 8;
10775+
);
10776+
10777+
if (*pos <= 251)
10778+
required_length= 1;
10779+
if (*pos == 252)
10780+
required_length= 3;
10781+
if (*pos == 253)
10782+
required_length= 4;
10783+
10784+
if (*max_bytes_available < required_length)
10785+
return NULL;
10786+
}
10787+
1076210788
*string_length= (size_t)net_field_length_ll((uchar **)buffer);
1076310789

1076410790
DBUG_EXECUTE_IF("sha256_password_scramble_too_long",
1076510791
*string_length= SIZE_T_MAX;
1076610792
);
1076710793

1076810794
size_t len_len= (size_t)(*buffer - begin);
10795+
10796+
DBUG_ASSERT((*max_bytes_available >= len_len) &&
10797+
(len_len == required_length));
1076910798

1077010799
if (*string_length > *max_bytes_available - len_len)
1077110800
return NULL;

0 commit comments

Comments
 (0)