Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

cifs: Replace zero-length arrays with flexible-array members

Zero-length arrays are deprecated[1] and we are moving towards
adopting C99 flexible-array members instead. So, replace zero-length
arrays in a couple of structures with flex-array members.

This helps with the ongoing efforts to tighten the FORTIFY_SOURCE
routines on memcpy() and help us make progress towards globally
enabling -fstrict-flex-arrays=3 [2].

Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#zero-length-and-one-element-arrays [1]
Link: https://gcc.gnu.org/pipermail/gcc-patches/2022-October/602902.html [2]
Link: https://github.com/KSPP/linux/issues/78
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Reviewed-by: Kees Cook <keescook@chromium.org>
Reviewed-by: Paulo Alcantara <pc@cjr.nz>
Signed-off-by: Steve French <stfrench@microsoft.com>

authored by

Gustavo A. R. Silva and committed by
Steve French
4e551dbd 9f5d1a8c

+2 -2
+2 -2
fs/cifs/ntlmssp.h
··· 83 83 SECURITY_BUFFER WorkstationName; /* RFC 1001 and ASCII */ 84 84 /* SECURITY_BUFFER for version info not present since we 85 85 do not set the version is present flag */ 86 - char DomainString[0]; 86 + char DomainString[]; 87 87 /* followed by WorkstationString */ 88 88 } __attribute__((packed)) NEGOTIATE_MESSAGE, *PNEGOTIATE_MESSAGE; 89 89 ··· 135 135 __le32 NegotiateFlags; 136 136 /* SECURITY_BUFFER for version info not present since we 137 137 do not set the version is present flag */ 138 - char UserString[0]; 138 + char UserString[]; 139 139 } __attribute__((packed)) AUTHENTICATE_MESSAGE, *PAUTHENTICATE_MESSAGE; 140 140 141 141 /*