Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx> --- src/storage/storage_backend_iscsi_direct.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/storage/storage_backend_iscsi_direct.c b/src/storage/storage_backend_iscsi_direct.c index 63225c533e..ca906357c3 100644 --- a/src/storage/storage_backend_iscsi_direct.c +++ b/src/storage/storage_backend_iscsi_direct.c @@ -117,10 +117,8 @@ virStorageBackendISCSIDirectSetAuth(struct iscsi_context *iscsi, &secret_value, &secret_size) < 0) return -1; - secret_str = g_new0(char, secret_size + 1); - memcpy(secret_str, secret_value, secret_size); + secret_str = g_strndup((char *)secret_value, secret_size); virSecureErase(secret_value, secret_size); - secret_str[secret_size] = '\0'; if (iscsi_set_initiator_username_pwd(iscsi, authdef->username, secret_str) < 0) { -- 2.39.1