[MDEV-12768] -Wformat-overflow compile warnings Created: 2017-05-10  Updated: 2017-05-11  Resolved: 2017-05-11

Status: Closed
Project: MariaDB Server
Component/s: Storage Engine - Connect
Affects Version/s: 10.2.6
Fix Version/s: 10.1.24, 10.0.31, 10.2.6, 10.3.1

Type: Bug Priority: Major
Reporter: Daniel Black Assignee: Olivier Bertrand
Resolution: Done Votes: 0
Labels: gcc7
Environment:

g++ --version
g++ (GCC) 7.1.1 20170504



 Description   

10.2 at 2980b0c348b1964b6efcadeba1082e02c2f5b45b

/home/danielgb/mariadb-10.2/storage/connect/plugutil.c: In function ‘PlugInit’:
/home/danielgb/mariadb-10.2/storage/connect/plugutil.c:160:23: warning: ‘%s’ directive writing up to 1023 bytes into a region of size 245 [-Wformat-overflow=]
       sprintf(errmsg, MSG(WORK_AREA), g->Message);
                       ^~~~~~~~~~~~~~~
In file included from /usr/include/stdio.h:936:0,
                 from /home/danielgb/mariadb-10.2/include/my_global.h:322,
                 from /home/danielgb/mariadb-10.2/storage/connect/plugutil.c:46:
/usr/include/powerpc64le-linux-gnu/bits/stdio2.h:33:10: note: ‘__builtin___sprintf_chk’ output between 12 and 1035 bytes into a destination of size 256
   return __builtin___sprintf_chk (__s, __USE_FORTIFY_LEVEL - 1,
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       __bos (__s), __fmt, __va_arg_pack ());
       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  

/home/danielgb/mariadb-10.2/storage/connect/plgdbutl.cpp: In function ‘int ExtractDate(char*, PDTP, int, int*)’:
/home/danielgb/mariadb-10.2/storage/connect/plgdbutl.cpp:767:24: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
     if ((n = *(int*)W[i]))
                        ^

/home/danielgb/mariadb-10.2/storage/connect/tabmul.cpp: In member function ‘virtual int TDBDIR::ReadDB(PGLOBAL)’:
/home/danielgb/mariadb-10.2/storage/connect/tabmul.cpp:789:5: warning: ‘%s’ directive writing up to 4095 bytes into a region of size 1024 [-Wformat-overflow=]
 int TDBDIR::ReadDB(PGLOBAL g)
     ^~~~~~
In file included from /usr/include/stdio.h:936:0,
                 from /home/danielgb/mariadb-10.2/include/my_global.h:322,
                 from /home/danielgb/mariadb-10.2/storage/connect/tabmul.cpp:39:
/usr/include/powerpc64le-linux-gnu/bits/stdio2.h:34:74: note: ‘__builtin___sprintf_chk’ output 3 or more bytes (assuming 4098) into a destination of size 1024
       __bos (__s), __fmt, __va_arg_pack ());
                                                                          ^
/home/danielgb/mariadb-10.2/storage/connect/tabmul.cpp: In member function ‘virtual int TDBSDR::ReadDB(PGLOBAL)’:
/home/danielgb/mariadb-10.2/storage/connect/tabmul.cpp:1107:5: warning: ‘%s’ directive writing up to 4095 bytes into a region of size 1024 [-Wformat-overflow=]
 int TDBSDR::ReadDB(PGLOBAL g)
     ^~~~~~
In file included from /usr/include/stdio.h:936:0,
                 from /home/danielgb/mariadb-10.2/include/my_global.h:322,
                 from /home/danielgb/mariadb-10.2/storage/connect/tabmul.cpp:39:
/usr/include/powerpc64le-linux-gnu/bits/stdio2.h:34:74: note: ‘__builtin___sprintf_chk’ output 3 or more bytes (assuming 4098) into a destination of size 1024
       __bos (__s), __fmt, __va_arg_pack ());
                                                                          ^
/home/danielgb/mariadb-10.2/storage/connect/tabmul.cpp: In member function ‘virtual int TDBDIR::GetMaxSize(PGLOBAL)’:
/home/danielgb/mariadb-10.2/storage/connect/tabmul.cpp:709:5: warning: ‘%s’ directive writing up to 4095 bytes into a region of size 1024 [-Wformat-overflow=]
 int TDBDIR::GetMaxSize(PGLOBAL g)
     ^~~~~~
In file included from /usr/include/stdio.h:936:0,
                 from /home/danielgb/mariadb-10.2/include/my_global.h:322,
                 from /home/danielgb/mariadb-10.2/storage/connect/tabmul.cpp:39:
/usr/include/powerpc64le-linux-gnu/bits/stdio2.h:34:74: note: ‘__builtin___sprintf_chk’ output 3 or more bytes (assuming 4098) into a destination of size 1024
       __bos (__s), __fmt, __va_arg_pack ());
                                                                          ^
/home/danielgb/mariadb-10.2/storage/connect/tabmul.cpp: In member function ‘int TDBSDR::FindInDir(PGLOBAL)’:
/home/danielgb/mariadb-10.2/storage/connect/tabmul.cpp:1003:5: warning: ‘%s’ directive writing up to 4095 bytes into a region of size 1024 [-Wformat-overflow=]
 int TDBSDR::FindInDir(PGLOBAL g)
     ^~~~~~
In file included from /usr/include/stdio.h:936:0,
                 from /home/danielgb/mariadb-10.2/include/my_global.h:322,
                 from /home/danielgb/mariadb-10.2/storage/connect/tabmul.cpp:39:
/usr/include/powerpc64le-linux-gnu/bits/stdio2.h:34:74: note: ‘__builtin___sprintf_chk’ output 3 or more bytes (assuming 4098) into a destination of size 1024
       __bos (__s), __fmt, __va_arg_pack ());
                                              

/home/danielgb/mariadb-10.2/storage/connect/tabvct.cpp: In member function ‘int VCTDEF::MakeFnPattern(char*)’:
/home/danielgb/mariadb-10.2/storage/connect/tabvct.cpp:175:5: warning: ‘%d’ directive writing between 1 and 10 bytes into a region of size 6 [-Wformat-overflow=]
 int VCTDEF::MakeFnPattern(char *fpat)
     ^~~~~~
/home/danielgb/mariadb-10.2/storage/connect/tabvct.cpp:175:5: note: directive argument in the range [1, 2147483647]
In file included from /usr/include/stdio.h:936:0,
                 from /home/danielgb/mariadb-10.2/include/my_global.h:322,
                 from /home/danielgb/mariadb-10.2/storage/connect/tabvct.cpp:37:
/usr/include/powerpc64le-linux-gnu/bits/stdio2.h:34:74: note: ‘__builtin___sprintf_chk’ output between 5 and 14 bytes into a destination of size 8
       __bos (__s), __fmt, __va_arg_pack ());
                                                   

/home/danielgb/mariadb-10.2/storage/connect/filamzip.cpp: In member function ‘virtual int UZXFAM::Cardinality(PGLOBAL)’:
/home/danielgb/mariadb-10.2/storage/connect/filamzip.cpp:878:5: warning: ‘%s’ directive writing up to 4095 bytes into a region of size 1019 [-Wformat-overflow=]
 int UZXFAM::Cardinality(PGLOBAL g)
     ^~~~~~
In file included from /usr/include/stdio.h:936:0,
                 from /home/danielgb/mariadb-10.2/include/my_global.h:322,
                 from /home/danielgb/mariadb-10.2/storage/connect/filamzip.cpp:19:
/usr/include/powerpc64le-linux-gnu/bits/stdio2.h:34:74: note: ‘__builtin___sprintf_chk’ output between 41 and 4156 bytes into a destination of size 1024
       __bos (__s), __fmt, __va_arg_pack ());
                                                                          ^
/home/danielgb/mariadb-10.2/storage/connect/filamzip.cpp: In member function ‘bool UNZIPUTL::openEntry(PGLOBAL)’:
/home/danielgb/mariadb-10.2/storage/connect/filamzip.cpp:618:6: warning: ‘%s’ directive writing up to 4095 bytes into a region of size 1013 [-Wformat-overflow=]
 bool UNZIPUTL::openEntry(PGLOBAL g)
      ^~~~~~~~
In file included from /usr/include/stdio.h:936:0,
                 from /home/danielgb/mariadb-10.2/include/my_global.h:322,
                 from /home/danielgb/mariadb-10.2/storage/connect/filamzip.cpp:19:
/usr/include/powerpc64le-linux-gnu/bits/stdio2.h:34:74: note: ‘__builtin___sprintf_chk’ output between 17 and 4122 bytes into a destination of size 1024
       __bos (__s), __fmt, __va_arg_pack ());
                                                                          ^
/home/danielgb/mariadb-10.2/storage/connect/filamzip.cpp: In member function ‘virtual int UZXFAM::GetNext(PGLOBAL)’:
/home/danielgb/mariadb-10.2/storage/connect/filamzip.cpp:933:5: warning: ‘%s’ directive writing up to 4095 bytes into a region of size 1019 [-Wformat-overflow=]
 int UZXFAM::GetNext(PGLOBAL g)
     ^~~~~~
/home/danielgb/mariadb-10.2/storage/connect/filamzip.cpp:933:5: note: using the range [-2147483648, 2147483647] for directive argument
In file included from /usr/include/stdio.h:936:0,
                 from /home/danielgb/mariadb-10.2/include/my_global.h:322,
                 from /home/danielgb/mariadb-10.2/storage/connect/filamzip.cpp:19:
/usr/include/powerpc64le-linux-gnu/bits/stdio2.h:34:74: note: ‘__builtin___sprintf_chk’ output between 41 and 4156 bytes into a destination of size 1024
       __bos (__s), __fmt, __va_arg_pack ());
                                                                          ^

/home/danielgb/mariadb-10.2/storage/connect/ha_connect.cc: In member function ‘CONDFIL* ha_connect::CheckCond(PGLOBAL, PCFIL, const Item*)’:
/home/danielgb/mariadb-10.2/storage/connect/ha_connect.cc:2744:10: warning: ‘ph2’ may be used uninitialized in this function [-Wmaybe-uninitialized]
       ph1= ph2 + strlen(ph2);
       ~~~^~~~~~~~~~~~~~~~~~~
/home/danielgb/mariadb-10.2/storage/connect/ha_connect.cc:2695:41: note: ‘ph2’ was declared here
     char      *pb0, *pb1, *pb2, *ph0, *ph1, *ph2;
                                         ^~~
/home/danielgb/mariadb-10.2/storage/connect/ha_connect.cc:2768:10: warning: ‘ph0’ may be used uninitialized in this function [-Wmaybe-uninitialized]
     *ph0 = 0;
     ~~~~~^~~
/home/danielgb/mariadb-10.2/storage/connect/ha_connect.cc:2695:29: note: ‘ph0’ was declared here
     char      *pb0, *pb1, *pb2, *ph0, *ph1, *ph2;
                             ^~~
/home/danielgb/mariadb-10.2/storage/connect/jsonudf.cpp: In function ‘my_bool CheckMemory(PGLOBAL, UDF_INIT*, UDF_ARGS*, uint, my_bool, my_bool, my_bool)’:
/home/danielgb/mariadb-10.2/storage/connect/jsonudf.cpp:1426:16: warning: ‘%s’ directive writing up to 1023 bytes into a region of size 245 [-Wformat-overflow=]
 static my_bool CheckMemory(PGLOBAL g, UDF_INIT *initid, UDF_ARGS *args, uint n,
                ^~~~~~~~~~~
In file included from /usr/include/stdio.h:936:0,
                 from /home/danielgb/mariadb-10.2/include/my_global.h:322,
                 from /home/danielgb/mariadb-10.2/storage/connect/jsonudf.cpp:10:
/usr/include/powerpc64le-linux-gnu/bits/stdio2.h:34:74: note: ‘__builtin___sprintf_chk’ output between 12 and 1035 bytes into a destination of size 256
       __bos (__s), __fmt, __va_arg_pack ());
                                                                          ^
/home/danielgb/mariadb-10.2/storage/connect/jsonudf.cpp: In function ‘my_bool CheckMemory(PGLOBAL, UDF_INIT*, UDF_ARGS*, uint, my_bool, my_bool, my_bool)’:
/home/danielgb/mariadb-10.2/storage/connect/jsonudf.cpp:1426:16: warning: ‘%s’ directive writing up to 1023 bytes into a region of size 245 [-Wformat-overflow=]
 static my_bool CheckMemory(PGLOBAL g, UDF_INIT *initid, UDF_ARGS *args, uint n,
                ^~~~~~~~~~~
In file included from /usr/include/stdio.h:936:0,
                 from /home/danielgb/mariadb-10.2/include/my_global.h:322,
                 from /home/danielgb/mariadb-10.2/storage/connect/jsonudf.cpp:10:
/usr/include/powerpc64le-linux-gnu/bits/stdio2.h:34:74: note: ‘__builtin___sprintf_chk’ output between 12 and 1035 bytes into a destination of size 256
       __bos (__s), __fmt, __va_arg_pack ());
                                                                          ^



 Comments   
Comment by Olivier Bertrand [ 2017-05-10 ]

I hopefully eliminated all these warnings.

Note that I still have a lot of warnings coming from the MariaDB included file:

C:\MariaDB-10.1\MariaDB\sql\sql_class.h(4286): warning C4311: 'type cast': pointer truncation from 'select_result_interceptor *const ' to 'ulong'
C:\MariaDB-10.1\MariaDB\sql\sql_class.h(4286): warning C4302: 'type cast': truncation from 'select_result_interceptor *const ' to 'ulong'

Comment by Daniel Black [ 2017-05-11 ]

Thanks bertrandop.

sql_class.h looks like it should be using %p with DBUG_PRINT and not casting this. This seems quite common in the rest of sql/*

Generated at Thu Feb 08 08:00:19 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.