mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-08-31 09:50:07 +03:00
virStorageBackendISCSIDirectSetAuth: Use 'g_strndup' to '\0' terminate data
Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
This commit is contained in:
@ -117,10 +117,8 @@ virStorageBackendISCSIDirectSetAuth(struct iscsi_context *iscsi,
|
|||||||
&secret_value, &secret_size) < 0)
|
&secret_value, &secret_size) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
secret_str = g_new0(char, secret_size + 1);
|
secret_str = g_strndup((char *)secret_value, secret_size);
|
||||||
memcpy(secret_str, secret_value, secret_size);
|
|
||||||
virSecureErase(secret_value, secret_size);
|
virSecureErase(secret_value, secret_size);
|
||||||
secret_str[secret_size] = '\0';
|
|
||||||
|
|
||||||
if (iscsi_set_initiator_username_pwd(iscsi,
|
if (iscsi_set_initiator_username_pwd(iscsi,
|
||||||
authdef->username, secret_str) < 0) {
|
authdef->username, secret_str) < 0) {
|
||||||
|
Reference in New Issue
Block a user