Description:
The newest gcc 9.2.1 from Ubuntu Bionic reports:
In file included from /usr/include/string.h:494,
from /data/mysql-server/mysql-8.0/include/my_dbug.h:37,
from /data/mysql-server/mysql-8.0/storage/innobase/include/os0file.h:44,
from /data/mysql-server/mysql-8.0/storage/innobase/os/os0file.cc:41:
In function ‘void* memcpy(void*, const void*, size_t)’,
inlined from ‘char* mem_strdupl(const char*, ulint)’ at /data/mysql-server/mysql-8.0/storage/innobase/include/mem0mem.ic:555:11,
inlined from ‘char* os_file_get_parent_dir(const char*)’ at /data/mysql-server/mysql-8.0/storage/innobase/os/os0file.cc:1794:22,
inlined from ‘dberr_t os_file_create_subdirs_if_needed(const char*)’ at /data/mysql-server/mysql-8.0/storage/innobase/os/os0file.cc:1863:40:
/usr/include/x86_64-linux-gnu/bits/string_fortified.h:34:33: error: ‘void* __builtin_memcpy(void*, const void*, long unsigned int)’ specified bound 18446744073709551615 exceeds maximum object size 9223372036854775807 [-Werror=stringop-overflow=]
34 | return __builtin___memcpy_chk (__dest, __src, __len, __bos0 (__dest));
| ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1plus: all warnings being treated as errors
How to repeat:
cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DMYSQL_MAINTAINER_MODE=ON -DBUILD_CONFIG=mysql_release -DFEATURE_SET=community
Suggested fix:
diff --git a/storage/innobase/os/os0file.cc b/storage/innobase/os/os0file.cc
index 7172ddc51aa..53dd69ab8be 100644
--- a/storage/innobase/os/os0file.cc
+++ b/storage/innobase/os/os0file.cc
@@ -1789,6 +1789,10 @@ static char *os_file_get_parent_dir(const char *path) {
return (NULL);
}
+ if (last_slash - path < 0) {
+ return (NULL);
+ }
+
/* Non-trivial directory component */
return (mem_strdupl(path, last_slash - path));