mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
storage: Properly terminate secrets
The virSecretGetSecretString() helper looks up a secret for given pool and returns its value in @secret_value and its length in @secret_value_size. However, the trailing '\0' is not included in either of the variables. This is because usually the value of the secret is passed to some encoder (usually base64 encoder) where the trailing zero must not be accounted for. However, in two places we actually want the string as we don't process it any further. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
e3e48d7cb8
commit
bfd91dc0c4
@ -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",
|
||||
|
@ -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) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user