Handle current UBSAN errors on Fedora

The fixed size array sa_lengths[1] is used dynamicly and UBSAN
warns about it:

[ 1110.124477] ------------[ cut here ]------------
[ 1110.126140] UBSAN: array-index-out-of-bounds in .../sa.c:766:21
[ 1110.130745] index 1 is out of range for type 'uint16_t [1]'

[ 1110.406282] UBSAN: array-index-out-of-bounds in .../sa.c:1934:29
[ 1110.411905] index 1 is out of range for type 'uint16_t [1]'

[ 1110.817251] UBSAN: array-index-out-of-bounds in .../sa.c:1734:24
[ 1110.821635] index 1 is out of range for type 'uint16_t [1]'

Fix the header file and make sa_lengths variable:
sa_lengths[1] -> sa_lengths[]

Signed-off-by: Tino Reichardt <milky-zfs@mcmilk.de>
This commit is contained in:
Tino Reichardt 2024-07-22 08:48:23 +02:00
parent aea42e1379
commit 11a2f1ed91
1 changed files with 1 additions and 1 deletions

View File

@ -177,7 +177,7 @@ typedef struct sa_hdr_phys {
* *
*/ */
uint16_t sa_layout_info; uint16_t sa_layout_info;
uint16_t sa_lengths[1]; /* optional sizes for variable length attrs */ uint16_t sa_lengths[]; /* optional sizes for variable length attrs */
/* ... Data follows the lengths. */ /* ... Data follows the lengths. */
} sa_hdr_phys_t; } sa_hdr_phys_t;