0002-Prevent-zero-length-array-members-in-asound.h.patch (2610B)
1 From 069cbc8a25155771af775ee084ba3519ed5a9602 Mon Sep 17 00:00:00 2001 2 From: Michael Forney <mforney@mforney.org> 3 Date: Mon, 30 Aug 2021 19:26:32 -0700 4 Subject: [PATCH] Prevent zero-length array members in asound.h 5 6 --- 7 include/uapi/sound/asound.h | 31 +++++++++++++++++++++---------- 8 1 file changed, 21 insertions(+), 10 deletions(-) 9 10 diff --git a/include/uapi/sound/asound.h b/include/uapi/sound/asound.h 11 index 628d46a0da92..23b0d301e83f 100644 12 --- a/include/uapi/sound/asound.h 13 +++ b/include/uapi/sound/asound.h 14 @@ -557,22 +557,30 @@ struct __snd_pcm_sync_ptr { 15 } c; 16 }; 17 18 +#if __BITS_PER_LONG == 32 19 #if defined(__BYTE_ORDER) ? __BYTE_ORDER == __BIG_ENDIAN : defined(__BIG_ENDIAN) 20 -typedef char __pad_before_uframe[sizeof(__u64) - sizeof(snd_pcm_uframes_t)]; 21 -typedef char __pad_after_uframe[0]; 22 +#define __PAD_BEFORE_UFRAME(x) char x[sizeof(__u64) - sizeof(snd_pcm_uframes_t)]; 23 #endif 24 25 #if defined(__BYTE_ORDER) ? __BYTE_ORDER == __LITTLE_ENDIAN : defined(__LITTLE_ENDIAN) 26 -typedef char __pad_before_uframe[0]; 27 -typedef char __pad_after_uframe[sizeof(__u64) - sizeof(snd_pcm_uframes_t)]; 28 +#define __PAD_AFTER_UFRAME(x) char x[sizeof(__u64) - sizeof(snd_pcm_uframes_t)]; 29 +#endif 30 +#endif 31 + 32 +#ifndef __PAD_BEFORE_UFRAME 33 +#define __PAD_BEFORE_UFRAME(x) 34 +#endif 35 + 36 +#ifndef __PAD_AFTER_UFRAME 37 +#define __PAD_AFTER_UFRAME(x) 38 #endif 39 40 struct __snd_pcm_mmap_status64 { 41 snd_pcm_state_t state; /* RO: state - SNDRV_PCM_STATE_XXXX */ 42 __u32 pad1; /* Needed for 64 bit alignment */ 43 - __pad_before_uframe __pad1; 44 + __PAD_BEFORE_UFRAME(__pad1) 45 snd_pcm_uframes_t hw_ptr; /* RO: hw ptr (0...boundary-1) */ 46 - __pad_after_uframe __pad2; 47 + __PAD_AFTER_UFRAME(__pad2) 48 struct __snd_timespec64 tstamp; /* Timestamp */ 49 snd_pcm_state_t suspended_state;/* RO: suspended stream state */ 50 __u32 pad3; /* Needed for 64 bit alignment */ 51 @@ -580,16 +588,19 @@ struct __snd_pcm_mmap_status64 { 52 }; 53 54 struct __snd_pcm_mmap_control64 { 55 - __pad_before_uframe __pad1; 56 + __PAD_BEFORE_UFRAME(__pad1) 57 snd_pcm_uframes_t appl_ptr; /* RW: appl ptr (0...boundary-1) */ 58 - __pad_before_uframe __pad2; // This should be __pad_after_uframe, but binary 59 + __PAD_BEFORE_UFRAME(__pad2) // This should be __pad_after_uframe, but binary 60 // backwards compatibility constraints prevent a fix. 61 62 - __pad_before_uframe __pad3; 63 + __PAD_BEFORE_UFRAME(__pad3) 64 snd_pcm_uframes_t avail_min; /* RW: min available frames for wakeup */ 65 - __pad_after_uframe __pad4; 66 + __PAD_AFTER_UFRAME(__pad4) 67 }; 68 69 +#undef __PAD_BEFORE_UFRAME 70 +#undef __PAD_AFTER_UFRAME 71 + 72 struct __snd_pcm_sync_ptr64 { 73 __u32 flags; 74 __u32 pad1; 75 -- 76 2.44.0 77