Describe the bug
vim is not _FORTIFY_SOURCE=2 clean (uses char[1] array). This causes the following problems:
- [minor]
configure.ac occasionally fails to catch new way to define _FORTIFY_SOURCE=2 and users get cryptic buffer overflow crashes
- [major] gcc assumes that array are 1-byte long and can produce invalid code (similar to what glibc does on
_FORTIFY_SOURCE=2 by introspecting array length)
To Reproduce
It's a downstream version of https://bugs.gentoo.org/706324 where gcc-10 was not detected and _FORTIFY_SOURCE=2 default was missed (worked around in #5580).
Expected behavior
vim should build and run on _FORTIFY_SOURCE=2 compiler.
Environment (please complete the following information):
- Vim version: 8.2.0114
- OS: Gentoo
- Terminal: alactitty-0.4.1
If vim can afford using flexible array members (https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html) it might use those:
--- a/src/structs.h
+++ b/src/structs.h
@@ -1414,7 +1414,7 @@ struct dictitem_S
{
typval_T di_tv; // type and value of the variable
char_u di_flags; // flags (only used for variable)
- char_u di_key[1]; // key (actually longer!)
+ char_u di_key[]; // key (actually longer!)
};
typedef struct dictitem_S dictitem_T;
I did not check if the rest of code does not rely on sizeof(struct dictitem_S).
Describe the bug
vim is not
_FORTIFY_SOURCE=2clean (useschar[1]array). This causes the following problems:configure.acoccasionally fails to catch new way to define_FORTIFY_SOURCE=2and users get cryptic buffer overflow crashes_FORTIFY_SOURCE=2by introspecting array length)To Reproduce
It's a downstream version of https://bugs.gentoo.org/706324 where gcc-10 was not detected and
_FORTIFY_SOURCE=2default was missed (worked around in #5580).Expected behavior
vim should build and run on
_FORTIFY_SOURCE=2compiler.Environment (please complete the following information):
If vim can afford using flexible array members (https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html) it might use those:
I did not check if the rest of code does not rely on sizeof(struct dictitem_S).