Home
last modified time | relevance | path

Searched hist:a7afacc4 (Results 1 – 1 of 1) sorted by relevance

/openbmc/dbus-sensors/src/
H A DNVMeBasicContext.cppa7afacc4 Wed Mar 30 19:51:28 CDT 2022 Andrew Jeffery <andrew@aj.id.au> NVMeBasicContext: Fix response vector size

73030639a5ba ("Enable cppcoreguidelines-avoid-goto checks") switches
from passing the backing store of the response vector to ::write() to
using an iterator over the response vector. This exposed the flaw that
the vector was never properly sized to accommodate the presence of the
response in the backing buffer[1], though from a memory-safety
perspective the backing buffer _was_ appropriately sized from the
reserve() call.

Resize the vector both before and after to ensure that a complete
response can be captured safely while also returning a vector that is
sized in accordance with the response.

It's likely the buffer management strategy could be improved here by
instead using std::array and std::span[2].

[1] https://github.com/openbmc/dbus-sensors/issues/18
[2] https://discord.com/channels/775381525260664832/867820390406422538/959228526811312169

Fixes: #18
Fixes: 73030639a5ba ("Enable cppcoreguidelines-avoid-goto checks")
Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
Change-Id: Ic2015a776389635765972084de75e33e7ea23d53