Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions phx_percona/percona/sql/sql_acl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10500,6 +10500,9 @@ char *get_56_lenc_string(char **buffer,
{
static char empty_string[1]= { '\0' };
char *begin= *buffer;
uchar *pos= (uchar *)begin;
size_t required_length= 9;


if (*max_bytes_available == 0)
return NULL;
Expand All @@ -10520,13 +10523,39 @@ char *get_56_lenc_string(char **buffer,
return empty_string;
}

/* Make sure we have enough bytes available for net_field_length_ll */
{
DBUG_EXECUTE_IF("buffer_too_short_3",
*pos= 252; *max_bytes_available= 2;
);
DBUG_EXECUTE_IF("buffer_too_short_4",
*pos= 253; *max_bytes_available= 3;
);
DBUG_EXECUTE_IF("buffer_too_short_9",
*pos= 254; *max_bytes_available= 8;
);

if (*pos <= 251)
required_length= 1;
if (*pos == 252)
required_length= 3;
if (*pos == 253)
required_length= 4;

if (*max_bytes_available < required_length)
return NULL;
}

*string_length= (size_t)net_field_length_ll((uchar **)buffer);

DBUG_EXECUTE_IF("sha256_password_scramble_too_long",
*string_length= SIZE_T_MAX;
);

size_t len_len= (size_t)(*buffer - begin);

DBUG_ASSERT((*max_bytes_available >= len_len) &&
(len_len == required_length));

if (*string_length > *max_bytes_available - len_len)
return NULL;
Expand Down