1001-Prevent-zero-sized-arrays.patch (2388B)
1 From a9a8b003bc97952fcc47d84b2ba9c490d90985e3 Mon Sep 17 00:00:00 2001 2 From: Michael Forney <mforney@mforney.org> 3 Date: Fri, 18 Feb 2022 01:40:22 -0800 4 Subject: [PATCH] Prevent zero-sized arrays 5 6 --- 7 src/xlat/btrfs_features_compat.h | 3 ++- 8 src/xlat/compat_ptrace_cmds.h | 3 ++- 9 src/xlat/sigprof_codes.h | 3 ++- 10 3 files changed, 6 insertions(+), 3 deletions(-) 11 12 diff --git a/src/xlat/btrfs_features_compat.h b/src/xlat/btrfs_features_compat.h 13 index 12136c495..cc5804a1b 100644 14 --- a/src/xlat/btrfs_features_compat.h 15 +++ b/src/xlat/btrfs_features_compat.h 16 @@ -15,13 +15,14 @@ extern const struct xlat btrfs_features_compat[]; 17 18 DIAG_PUSH_IGNORE_TAUTOLOGICAL_CONSTANT_COMPARE 19 static const struct xlat_data btrfs_features_compat_xdata[] = { 20 + {0} 21 }; 22 # if !(defined HAVE_M32_MPERS || defined HAVE_MX32_MPERS) 23 static 24 # endif 25 const struct xlat btrfs_features_compat[1] = { { 26 .data = btrfs_features_compat_xdata, 27 - .size = ARRAY_SIZE(btrfs_features_compat_xdata), 28 + .size = ARRAY_SIZE(btrfs_features_compat_xdata) - 1, 29 .type = XT_NORMAL, 30 .flags_mask = 0 31 , 32 diff --git a/src/xlat/compat_ptrace_cmds.h b/src/xlat/compat_ptrace_cmds.h 33 index 9a7fc96b1..a29567689 100644 34 --- a/src/xlat/compat_ptrace_cmds.h 35 +++ b/src/xlat/compat_ptrace_cmds.h 36 @@ -225,11 +225,12 @@ static const struct xlat_data compat_ptrace_cmds_xdata[] = { 37 #define XLAT_VAL_9 ((unsigned) (COMPAT_PTRACE_SETHBPREGS)) 38 #define XLAT_STR_9 STRINGIFY(COMPAT_PTRACE_SETHBPREGS) 39 #endif 40 + {0} 41 }; 42 static 43 const struct xlat compat_ptrace_cmds[1] = { { 44 .data = compat_ptrace_cmds_xdata, 45 - .size = ARRAY_SIZE(compat_ptrace_cmds_xdata), 46 + .size = ARRAY_SIZE(compat_ptrace_cmds_xdata) - 1, 47 .type = XT_SORTED, 48 .flags_mask = 0 49 # ifdef XLAT_VAL_0 50 diff --git a/src/xlat/sigprof_codes.h b/src/xlat/sigprof_codes.h 51 index bc61fdc8f..88f043ab9 100644 52 --- a/src/xlat/sigprof_codes.h 53 +++ b/src/xlat/sigprof_codes.h 54 @@ -20,13 +20,14 @@ static const struct xlat_data sigprof_codes_xdata[] = { 55 #define XLAT_VAL_0 ((unsigned) (PROF_SIG)) 56 #define XLAT_STR_0 STRINGIFY(PROF_SIG) 57 #endif 58 + {0} 59 }; 60 # if !(defined HAVE_M32_MPERS || defined HAVE_MX32_MPERS) 61 static 62 # endif 63 const struct xlat sigprof_codes[1] = { { 64 .data = sigprof_codes_xdata, 65 - .size = ARRAY_SIZE(sigprof_codes_xdata), 66 + .size = ARRAY_SIZE(sigprof_codes_xdata) - 1, 67 .type = XT_NORMAL, 68 .flags_mask = 0 69 # ifdef XLAT_VAL_0 70 -- 71 2.34.1 72