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
1 file changed
tree: c343e0e8d410a3c0fabd579d45bfb6114fbfa989
  1. include/
  2. service_files/
  3. src/
  4. subprojects/
  5. tests/
  6. .clang-format
  7. .clang-ignore
  8. .clang-tidy
  9. .gitignore
  10. Jenkinsfile
  11. LICENSE
  12. MAINTAINERS
  13. meson.build
  14. meson_options.txt
  15. OWNERS
  16. README.md
README.md

dbus-sensors

dbus-sensors is a collection of sensor applications that provide the xyz.openbmc_project.Sensor collection of interfaces. They read sensor values from hwmon, d-bus, or direct driver access to provide readings. Some advance non-sensor features such as fan presence, pwm control, and automatic cpu detection (x86) are also supported.

key features

  • runtime re-configurable from d-bus (entity-manager or the like)

  • isolated: each sensor type is isolated into its own daemon, so a bug in one sensor is unlikely to affect another, and single sensor modifications are possible

  • async single-threaded: uses sdbusplus/asio bindings

  • multiple data inputs: hwmon, d-bus, direct driver access

sensor documentation