News for hackers. Stuff that matters.
Re:Legitimate Use of Variable Length Arrays by michaelt on Monday October 28, 2019 @10:22AM (#21377250)
>If there’s any risk that nmemb is too large, it must be guarded. [...] However, if median is expected to safely accommodate COPY_MAX elements, it may as well always allocate an array of this size. If it can’t, then that’s not a safe maximum.

Et voilà, a library function that could have been portable between the smallest microcontroller and the largest workstation becomes restricted to a single application.

Re:Legitimate Use of Variable Length Arrays by theamk on Monday October 28, 2019 @11:20AM (#21377743)
Um, no? That COPY_MAX would still need a different value between small MCU and full-blown PC.

Not to mention that using stack allocation on low-memory device is extremely dangerous... at least with malloc you get a nice diagnostic, while alloca will just do random program damage.

Re:Legitimate Use of Variable Length Arrays by lonelappde on Monday October 28, 2019 @05:03PM (#21381636)
Isn't that like choosing your poison? If you have a low memory device, you need to statically guarantee safety and reject oversized inputs. Crashing your embedded device may work if your are a server with a client that knows to retry another backend, but isn't an elegant solution if it disables your car's brakes.
Re:Legitimate Use of Variable Length Arrays by bdisnainc on Monday October 28, 2019 @11:55AM (#21378061)
It does not do random damage, you get a segmentation fault in most systems.

In really small embedded you should not be allocating anything meaningful in the stack anyway.

Re:Legitimate Use of Variable Length Arrays by Gibbon1 on Monday October 28, 2019 @11:01PM (#21383952)
In small embedded things are either statically allocated or allocated on the stack. There is no heap.