On 20/01/2022 06.35, Andy Shevchenko wrote: > On Mon, Jan 17, 2022 at 4:30 PM Hector Martin <marcan@xxxxxxxxx> wrote: >> >> If boardrev is missing from the NVRAM we add a default one, but this >> might need more space in the output buffer than was allocated. Ensure >> we have enough padding for this in the buffer. > > Do you know this ahead (before allocation happens)? > If yes, the size change should happen conditionally. > > Alternatively, krealloc() may be used. We don't know if we will have to add a boardrev until we find it's missing. The buffer is already oversized anyway, as its size is computed based on the input NVRAM size, while comments and such will be removed. This is just increasing the existing worst-case allocation to properly account for the true worst-case case. I don't think trying to keep the buffer perfectly sized buys us anything here, since it will be freed after download anyway. There's no point in saving a few bytes of memory in the interim. -- Hector Martin (marcan@xxxxxxxxx) Public Key: https://mrcn.st/pub