Skip to content

Commit d99dcce

Browse files
author
G Manasa
committed
Bug#30139031: GET_PACKET_LENGTH() SHOULD RETURN ULONG
Description: There is an integer loss of precision in a function during connection leading to a diverted control flow. Analysis: A function which is supposed to return ulong returned unit which leads to loss of integer precision. This lead to a diverted control flow. Fix: Change the return value of the function to ulong instead of uint. RB#24097
1 parent 010221a commit d99dcce

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

sql/auth/sql_authentication.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1889,7 +1889,7 @@ static int server_mpvio_read_packet(MYSQL_PLUGIN_VIO *param, uchar **buf)
18891889
protocol->read_packet();
18901890
pkt_len= protocol->get_packet_length();
18911891
}
1892-
1892+
DBUG_EXECUTE_IF("simulate_packet_error", pkt_len = packet_error;);
18931893
if (pkt_len == packet_error)
18941894
goto err;
18951895

@@ -2197,7 +2197,7 @@ acl_authenticate(THD *thd, enum_server_command command)
21972197
/* acl_authenticate() takes the data from net->read_pos */
21982198
thd->get_protocol_classic()->get_net()->read_pos=
21992199
thd->get_protocol_classic()->get_raw_packet();
2200-
DBUG_PRINT("info", ("com_change_user_pkt_len=%u",
2200+
DBUG_PRINT("info", ("com_change_user_pkt_len=%lu",
22012201
mpvio.protocol->get_packet_length()));
22022202

22032203
if (command == COM_CHANGE_USER)

sql/protocol_classic.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#ifndef PROTOCOL_CLASSIC_INCLUDED
22
#define PROTOCOL_CLASSIC_INCLUDED
33

4-
/* Copyright (c) 2002, 2018, Oracle and/or its affiliates. All rights reserved.
4+
/* Copyright (c) 2002, 2020, Oracle and/or its affiliates. All rights reserved.
55
66
This program is free software; you can redistribute it and/or modify
77
it under the terms of the GNU General Public License, version 2.0,
@@ -202,7 +202,7 @@ class Protocol_classic : public Protocol
202202
/* Return packet string */
203203
String *get_packet();
204204
/* return packet length */
205-
uint get_packet_length() { return packet_length; }
205+
ulong get_packet_length() { return packet_length; }
206206
/* Return raw packet buffer */
207207
uchar *get_raw_packet() { return raw_packet; }
208208
/* Set read timeout */

sql/sql_parse.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
1+
/* Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
22
33
This program is free software; you can redistribute it and/or modify
44
it under the terms of the GNU General Public License, version 2.0,
@@ -1017,7 +1017,7 @@ bool do_command(THD *thd)
10171017
command_name[command].str));
10181018

10191019
DBUG_PRINT("info", ("packet: '%*.s'; command: %d",
1020-
thd->get_protocol_classic()->get_packet_length(),
1020+
(int)thd->get_protocol_classic()->get_packet_length(),
10211021
thd->get_protocol_classic()->get_raw_packet(), command));
10221022
if (thd->get_protocol_classic()->bad_packet)
10231023
DBUG_ASSERT(0); // Should be caught earlier

0 commit comments

Comments
 (0)