Commit 70960bd3 authored by Marko Mäkelä's avatar Marko Mäkelä

UBSAN: Fix a bit shift overflow

Shifting a 16-bit type by 16 bits is undefined behaviour.
The result is at least 32 bits, so let us cast the shift operand
to a wider type before shifting.
parent af40a2b4
/* Copyright (c) 2003, 2016, Oracle and/or its affiliates. /* Copyright (c) 2003, 2016, Oracle and/or its affiliates.
Copyright (c) 2009, 2017, MariaDB Copyright (c) 2009, 2020, MariaDB
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
...@@ -3295,7 +3295,7 @@ CLI_MYSQL_REAL_CONNECT(MYSQL *mysql,const char *host, const char *user, ...@@ -3295,7 +3295,7 @@ CLI_MYSQL_REAL_CONNECT(MYSQL *mysql,const char *host, const char *user,
/* New protocol with 16 bytes to describe server characteristics */ /* New protocol with 16 bytes to describe server characteristics */
mysql->server_language=end[2]; mysql->server_language=end[2];
mysql->server_status=uint2korr(end+3); mysql->server_status=uint2korr(end+3);
mysql->server_capabilities|= uint2korr(end+5) << 16; mysql->server_capabilities|= ((unsigned) uint2korr(end+5)) << 16;
pkt_scramble_len= end[7]; pkt_scramble_len= end[7];
if (pkt_scramble_len < 0) if (pkt_scramble_len < 0)
{ {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment