Commit 08eeefc7 authored by Daniel Verkamp's avatar Daniel Verkamp Committed by Jim Harris
Browse files

ut/lvol: remove use of sprintf()



sprintf() has no bounds checks, and in this case it is actually
overwriting a buffer allocated with spdk_sprintf_alloc(), which isn't
guaranteed to be big enough for the name we want to place in it.

Rather than trying to rewrite the name in place, just free the old one
and allocate a new one.

Change-Id: Ia6ea17c2f0c8e4ed4995946356b8a09ba2a02cbf
Signed-off-by: default avatarDaniel Verkamp <daniel.verkamp@intel.com>
Reviewed-on: https://review.gerrithub.io/382507


Tested-by: default avatarSPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: default avatarDariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
parent 9760edb0
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -469,7 +469,9 @@ ut_lvol_resize(void)
	CU_ASSERT(rc != 0);

	/* Resize with correct bdev name, but wrong lvol name */
	sprintf(g_lvol->name, "wrong name");
	free(g_lvol->name);
	g_lvol->name = strdup("wrong name");
	SPDK_CU_ASSERT_FATAL(g_lvol->name != NULL);
	rc = vbdev_lvol_resize(g_base_bdev->name, 20, vbdev_lvol_resize_complete, NULL);
	CU_ASSERT(rc != 0);