fix: 1 byte overflow in UuidView
authorMichael Jeanson <mjeanson@efficios.com>
Mon, 27 Feb 2023 22:35:30 +0000 (17:35 -0500)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Tue, 7 Mar 2023 21:58:07 +0000 (16:58 -0500)
commit99ddb79d9af777d20b4b138f918249a473cbf710
treef07c5985a788e8cfaf5f249cb4c8351260055c16
parentf8b833e602f434d14bf8b7b87f876e91c4b6767f
fix: 1 byte overflow in UuidView

The string() method of UuidView allocates a buffer of BT_UUID_STR_LEN
bytes and then calls bt_uuid_to_str() that prints a C string of
BT_UUID_STR_LEN + 1 bytes (including the terminating null byte ('\0'))
which results in a 1 byte overflow.

Directly use an std::string instead of a char array, resize it to
BT_UUID_STR_LEN which implicitly adds the terminating null byte and then
use the data method to write to the underlying C string.

Change-Id: Ifa6f0322c219e28dec78b8680763b3126a1e513a
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/9594
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
src/cpp-common/uuid-view.hpp
This page took 0.026212 seconds and 4 git commands to generate.