logo

oasis

Own branch of Oasis Linux (upstream: <https://git.sr.ht/~mcf/oasis/>) git clone https://anongit.hacktivis.me/git/oasis.git

0002-Prevent-zero-length-array-members-in-asound.h.patch (2610B)


  1. From 9ede9b68b8fc87052bd49b55c15e4faaf7c7ff4f 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. include/uapi/sound/asound.h | 31 +++++++++++++++++++++----------
  7. 1 file changed, 21 insertions(+), 10 deletions(-)
  8. diff --git a/include/uapi/sound/asound.h b/include/uapi/sound/asound.h
  9. index 4cd513215bcd..c17462583d67 100644
  10. --- a/include/uapi/sound/asound.h
  11. +++ b/include/uapi/sound/asound.h
  12. @@ -558,22 +558,30 @@ struct __snd_pcm_sync_ptr {
  13. } c;
  14. };
  15. +#if __BITS_PER_LONG == 32
  16. #if defined(__BYTE_ORDER) ? __BYTE_ORDER == __BIG_ENDIAN : defined(__BIG_ENDIAN)
  17. -typedef char __pad_before_uframe[sizeof(__u64) - sizeof(snd_pcm_uframes_t)];
  18. -typedef char __pad_after_uframe[0];
  19. +#define __PAD_BEFORE_UFRAME(x) char x[sizeof(__u64) - sizeof(snd_pcm_uframes_t)];
  20. #endif
  21. #if defined(__BYTE_ORDER) ? __BYTE_ORDER == __LITTLE_ENDIAN : defined(__LITTLE_ENDIAN)
  22. -typedef char __pad_before_uframe[0];
  23. -typedef char __pad_after_uframe[sizeof(__u64) - sizeof(snd_pcm_uframes_t)];
  24. +#define __PAD_AFTER_UFRAME(x) char x[sizeof(__u64) - sizeof(snd_pcm_uframes_t)];
  25. +#endif
  26. +#endif
  27. +
  28. +#ifndef __PAD_BEFORE_UFRAME
  29. +#define __PAD_BEFORE_UFRAME(x)
  30. +#endif
  31. +
  32. +#ifndef __PAD_AFTER_UFRAME
  33. +#define __PAD_AFTER_UFRAME(x)
  34. #endif
  35. struct __snd_pcm_mmap_status64 {
  36. snd_pcm_state_t state; /* RO: state - SNDRV_PCM_STATE_XXXX */
  37. __u32 pad1; /* Needed for 64 bit alignment */
  38. - __pad_before_uframe __pad1;
  39. + __PAD_BEFORE_UFRAME(__pad1)
  40. snd_pcm_uframes_t hw_ptr; /* RO: hw ptr (0...boundary-1) */
  41. - __pad_after_uframe __pad2;
  42. + __PAD_AFTER_UFRAME(__pad2)
  43. struct __snd_timespec64 tstamp; /* Timestamp */
  44. snd_pcm_state_t suspended_state;/* RO: suspended stream state */
  45. __u32 pad3; /* Needed for 64 bit alignment */
  46. @@ -581,16 +589,19 @@ struct __snd_pcm_mmap_status64 {
  47. };
  48. struct __snd_pcm_mmap_control64 {
  49. - __pad_before_uframe __pad1;
  50. + __PAD_BEFORE_UFRAME(__pad1)
  51. snd_pcm_uframes_t appl_ptr; /* RW: appl ptr (0...boundary-1) */
  52. - __pad_before_uframe __pad2; // This should be __pad_after_uframe, but binary
  53. + __PAD_BEFORE_UFRAME(__pad2) // This should be __pad_after_uframe, but binary
  54. // backwards compatibility constraints prevent a fix.
  55. - __pad_before_uframe __pad3;
  56. + __PAD_BEFORE_UFRAME(__pad3)
  57. snd_pcm_uframes_t avail_min; /* RW: min available frames for wakeup */
  58. - __pad_after_uframe __pad4;
  59. + __PAD_AFTER_UFRAME(__pad4)
  60. };
  61. +#undef __PAD_BEFORE_UFRAME
  62. +#undef __PAD_AFTER_UFRAME
  63. +
  64. struct __snd_pcm_sync_ptr64 {
  65. __u32 flags;
  66. __u32 pad1;
  67. --
  68. 2.45.2