Skip to content

Commit

Permalink
treewide: Replace zero-length arrays with flexible-array members
Browse files Browse the repository at this point in the history
BugLink: https://bugs.launchpad.net/bugs/1970977

There is a regular need in the kernel to provide a way to declare
having a dynamically sized set of trailing elements in a structure.
Kernel code should always use “flexible array members”[1] for these
cases. The older style of one-element or zero-length arrays should
no longer be used[2].

This code was transformed with the help of Coccinelle:
(next-20220214$ spatch --jobs $(getconf _NPROCESSORS_ONLN) --sp-file script.cocci --include-headers --dir . > output.patch)

@@
identifier S, member, array;
type T1, T2;
@@

struct S {
  ...
  T1 member;
  T2 array[
- 0
  ];
};

UAPI and wireless changes were intentionally excluded from this patch
and will be sent out separately.

[1] https://en.wikipedia.org/wiki/Flexible_array_member
[2] https://www.kernel.org/doc/html/v5.16/process/deprecated.html#zero-length-and-one-element-arrays

Link: KSPP/linux#78
Reviewed-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
(cherry-picked from 92f0697ecd664e753515509689e96b40e750b5ed git://git.samba.org/sfrench/cifs-2.6.git)
[rtg - the full treewide commit was much more carnage then was needed for cifs]
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
Acked-by: Philip Cox <philip.cox@canonical.com>
Acked-by: Joseph Salisbury <joseph.salisbury@canonical.com>
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
  • Loading branch information
GustavoARSilva authored and Ubuntu Kernel Bot committed Jun 23, 2024
1 parent 39fa488 commit 033a453
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion fs/cifs/ntlmssp.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ struct negotiate_message {
SECURITY_BUFFER WorkstationName; /* RFC 1001 and ASCII */
struct ntlmssp_version Version;
/* SECURITY_BUFFER */
char DomainString[0];
char DomainString[];
/* followed by WorkstationString */
} __packed;

Expand Down

0 comments on commit 033a453

Please sign in to comment.