Re:How to use the new counted_by attribute in C (and Linux)
by dzaima on Saturday July 20, 2024 @07:32PM
(#41021052)
With a flexible array member, updating the length in-place is rather infrequent, at least in certain use cases (given that to expand it you might have to reallocate the entire struct, including the count field).
What it helps with is fortified builds, as now the compiler/libc can now get an upper bound on the intended size, whereas before it's had to just assume flexible array members are infinitely-long and thus is largely never able to add bounds checking.
What it helps with is fortified builds, as now the compiler/libc can now get an upper bound on the intended size, whereas before it's had to just assume flexible array members are infinitely-long and thus is largely never able to add bounds checking.