diff --git a/src/storage/storage_backend_iscsi.c b/src/storage/storage_backend_iscsi.c index 6242cd0fac26b2b4fab6d4b0c9c64a8685b5cea1..55fe47f5e107200e59ac9980b60fe3a17f93e649 100644 --- a/src/storage/storage_backend_iscsi.c +++ b/src/storage/storage_backend_iscsi.c @@ -303,6 +303,11 @@ virStorageBackendISCSISetAuth(const char *portal, &secret_value, &secret_size) < 0) goto cleanup; + if (VIR_REALLOC_N(secret_value, secret_size + 1) < 0) + goto cleanup; + + secret_value[secret_size] = '\0'; + if (virISCSINodeUpdate(portal, source->devices[0].path, "node.session.auth.authmethod", diff --git a/src/storage/storage_backend_iscsi_direct.c b/src/storage/storage_backend_iscsi_direct.c index 1624066e9c06b85b427436ed36f1522e6df5167f..0d7d6ba9c36e83727891c6aff9df5017af61221f 100644 --- a/src/storage/storage_backend_iscsi_direct.c +++ b/src/storage/storage_backend_iscsi_direct.c @@ -115,6 +115,11 @@ virStorageBackendISCSIDirectSetAuth(struct iscsi_context *iscsi, &secret_value, &secret_size) < 0) goto cleanup; + if (VIR_REALLOC_N(secret_value, secret_size + 1) < 0) + goto cleanup; + + secret_value[secret_size] = '\0'; + if (iscsi_set_initiator_username_pwd(iscsi, authdef->username, (const char *)secret_value) < 0) {