Skip to content

Commit 70960bd

Browse files
committed
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.
1 parent af40a2b commit 70960bd

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

sql-common/client.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* Copyright (c) 2003, 2016, Oracle and/or its affiliates.
2-
Copyright (c) 2009, 2017, MariaDB
2+
Copyright (c) 2009, 2020, MariaDB
33
44
This program is free software; you can redistribute it and/or modify
55
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,
32953295
/* New protocol with 16 bytes to describe server characteristics */
32963296
mysql->server_language=end[2];
32973297
mysql->server_status=uint2korr(end+3);
3298-
mysql->server_capabilities|= uint2korr(end+5) << 16;
3298+
mysql->server_capabilities|= ((unsigned) uint2korr(end+5)) << 16;
32993299
pkt_scramble_len= end[7];
33003300
if (pkt_scramble_len < 0)
33013301
{

0 commit comments

Comments
 (0)