bdev_ut: UB due to small buffer

bdev_multi_allocation tries to write four characters, an integer between
0 and INT_MAX, and a nul byte into 10 characters. That requires at least
15 characters.

This leads to build failures with "make CONFIG_DEBUG=n CONFIG_UBSAN=y".

Change-Id: I8cb9fd4ede31ae24809e4a04fd60a67dae3a0ac4
Signed-off-by: Mike Gerdts <mgerdts@nvidia.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/11261
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
Community-CI: Mellanox Build Bot
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com>
This commit is contained in:
Mike Gerdts 2022-01-29 10:08:14 -06:00 committed by Jim Harris
parent 7caa514f3c
commit 5eb363cf8c

View File

@ -4805,7 +4805,7 @@ static void
bdev_multi_allocation(void)
{
const int max_bdev_num = 1024 * 16;
char name[max_bdev_num][10];
char name[max_bdev_num][16];
char noexist_name[] = "invalid_bdev";
struct spdk_bdev *bdev[max_bdev_num];
int i, j;