Bug #96433 incorrect length in read_ok_ex()
Submitted: 6 Aug 2019 9:28 Modified: 13 Aug 2019 16:33
Reporter: Przemysław Skibiński (OCA) Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Compiling Severity:S3 (Non-critical)
Version:5.7.27 OS:Any
Assigned to: CPU Architecture:Any

[6 Aug 2019 9:28] Przemysław Skibiński
Description:
clang-8 found a bug in mysql-5.7.27/sql-common/client.c:805
 
size_t length = data->length > (sizeof(charset_name) - 1)
                                  ? sizeof(charset_name - 1)
                                  : data->length;

sizeof(charset_name - 1), which is always 4, should be replaced with (sizeof(charset_name) - 1)

How to repeat:
the error is obvious
[6 Aug 2019 18:21] MySQL Verification Team
HI,

Would you be so kind and provide very detailed analysis on OS, it's version, cmake version, make version, compiler make and version. Last, but not least which source tarball did you exactly download.

Also, how did you run cmake, with which option. In other words , we need the entire procedure in detail.

Thanks in advance.
[7 Aug 2019 8:09] Terje Røsten
hi!

Thanks for your report!

Verified by:

$ export CC=/usr/bin/clang-8
$ export CXX=/usr/bin/clang++-8

$ mkdir b && cd b
$ cmake ..
$ cd libmysql
$ make VERBOSE=1
...

cd /work/mysql-5.7-clean/b/libmysql && /usr/bin/clang-8 -DHAVE_CONFIG_H -DHAVE_LIBEVENT2 -DHAVE_OPENSSL -DHAVE_TLSv13 -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -I/work/mysql-5.7-clean/b/include -I/work/mysql-5.7-clean/extra/rapidjson/include -I/work/mysql-5.7-clean/b/libbinlogevents/include -I/work/mysql-5.7-clean/libbinlogevents/export -I/work/mysql-5.7-clean/include -I/work/mysql-5.7-clean/libmysql -I/work/mysql-5.7-clean/regex -I/work/mysql-5.7-clean/sql -I/work/mysql-5.7-clean/strings -isystem /work/mysql-5.7-clean/zlib -isystem /work/mysql-5.7-clean/b/zlib  -Wall -Wextra -Wformat-security -Wvla -Wwrite-strings -Wdeclaration-after-statement -O3 -g -fno-omit-frame-pointer -fno-strict-aliasing -DDBUG_OFF -fPIC   -D CLIENT_PROTOCOL_TRACING -o CMakeFiles/clientlib.dir/__/sql-common/client.c.o   -c /work/mysql-5.7-clean/sql-common/client.c
/work/mysql-5.7-clean/sql-common/client.c:817:57: warning: sizeof on pointer operation will return size of 'char *' instead of 'char [256]'
      [-Wsizeof-array-decay]
                                  ? sizeof(charset_name - 1)
                                           ~~~~~~~~~~~~ ^
[7 Aug 2019 8:09] Tor Didriksen
current head of 5.7:

sql-common/client.c:817:57: error: sizeof on pointer operation will return size of 'char *'
      instead of 'char [256]' [-Werror,-Wsizeof-array-decay]
                                  ? sizeof(charset_name - 1)
[13 Aug 2019 16:33] Paul DuBois
Posted by developer:
 
Fixed in 5.7.28, 8.0.19.

Code cleanup. No changelog entry needed.