Instead of using md5_buffer from gnulib directly.
Signed-off-by: Ján Tomko <jtomko(a)redhat.com>
---
src/esx/esx_network_driver.c | 13 +++++++++----
src/esx/esx_storage_backend_iscsi.c | 19 +++++++++++++------
src/esx/esx_storage_backend_vmfs.c | 9 +++++----
3 files changed, 27 insertions(+), 14 deletions(-)
diff --git a/src/esx/esx_network_driver.c b/src/esx/esx_network_driver.c
index b19c06a4cb..7386efb0f5 100644
--- a/src/esx/esx_network_driver.c
+++ b/src/esx/esx_network_driver.c
@@ -33,6 +33,7 @@
#include "esx_vi.h"
#include "esx_vi_methods.h"
#include "esx_util.h"
+#include "vircrypto.h"
#include "virstring.h"
#define VIR_FROM_THIS VIR_FROM_ESX
@@ -152,7 +153,8 @@ esxNetworkLookupByUUID(virConnectPtr conn, const unsigned char *uuid)
for (hostVirtualSwitch = hostVirtualSwitchList; hostVirtualSwitch;
hostVirtualSwitch = hostVirtualSwitch->_next) {
- md5_buffer(hostVirtualSwitch->key, strlen(hostVirtualSwitch->key), md5);
+ if (virCryptoHashBuf(VIR_CRYPTO_HASH_MD5, hostVirtualSwitch->key, md5) <
0)
+ goto cleanup;
if (memcmp(uuid, md5, VIR_UUID_BUFLEN) == 0)
break;
@@ -201,7 +203,8 @@ esxNetworkLookupByName(virConnectPtr conn, const char *name)
* The MD5 sum of the key can be used as UUID, assuming MD5 is considered
* to be collision-free enough for this use case.
*/
- md5_buffer(hostVirtualSwitch->key, strlen(hostVirtualSwitch->key), md5);
+ if (virCryptoHashBuf(VIR_CRYPTO_HASH_MD5, hostVirtualSwitch->key, md5) < 0)
+ return NULL;
network = virGetNetwork(conn, hostVirtualSwitch->name, md5);
@@ -464,7 +467,8 @@ esxNetworkDefineXML(virConnectPtr conn, const char *xml)
goto cleanup;
}
- md5_buffer(hostVirtualSwitch->key, strlen(hostVirtualSwitch->key), md5);
+ if (virCryptoHashBuf(VIR_CRYPTO_HASH_MD5, hostVirtualSwitch->key, md5) < 0)
+ goto cleanup;
network = virGetNetwork(conn, hostVirtualSwitch->name, md5);
@@ -655,7 +659,8 @@ esxNetworkGetXMLDesc(virNetworkPtr network_, unsigned int flags)
goto cleanup;
}
- md5_buffer(hostVirtualSwitch->key, strlen(hostVirtualSwitch->key),
def->uuid);
+ if (virCryptoHashBuf(VIR_CRYPTO_HASH_MD5, hostVirtualSwitch->key, def->uuid)
< 0)
+ goto cleanup;
if (VIR_STRDUP(def->name, hostVirtualSwitch->name) < 0)
goto cleanup;
diff --git a/src/esx/esx_storage_backend_iscsi.c b/src/esx/esx_storage_backend_iscsi.c
index b106c517e8..42b52214d1 100644
--- a/src/esx/esx_storage_backend_iscsi.c
+++ b/src/esx/esx_storage_backend_iscsi.c
@@ -37,6 +37,7 @@
#include "esx_vi.h"
#include "esx_vi_methods.h"
#include "esx_util.h"
+#include "vircrypto.h"
#include "virstring.h"
#define VIR_FROM_THIS VIR_FROM_ESX
@@ -180,7 +181,8 @@ esxStoragePoolLookupByName(virConnectPtr conn,
* but iScsiName (or widely known as IQN) is unique across the multiple
* hosts, using it to compute key
*/
- md5_buffer(target->iScsiName, strlen(target->iScsiName), md5);
+ if (virCryptoHashBuf(VIR_CRYPTO_HASH_MD5, target->iScsiName, md5) < 0)
+ goto cleanup;
pool = virGetStoragePool(conn, name, md5, &esxStorageBackendISCSI, NULL);
@@ -218,7 +220,8 @@ esxStoragePoolLookupByUUID(virConnectPtr conn,
for (target = hostInternetScsiHba->configuredStaticTarget;
target; target = target->_next) {
- md5_buffer(target->iScsiName, strlen(target->iScsiName), md5);
+ if (virCryptoHashBuf(VIR_CRYPTO_HASH_MD5, target->iScsiName, md5) < 0)
+ goto cleanup;
if (memcmp(uuid, md5, VIR_UUID_BUFLEN) == 0)
break;
@@ -456,7 +459,8 @@ esxStorageVolLookupByName(virStoragePoolPtr pool,
* compute MD5 hash to transform it to an acceptable
* libvirt format
*/
- md5_buffer(scsiLun->uuid, strlen(scsiLun->uuid), md5);
+ if (virCryptoHashBuf(VIR_CRYPTO_HASH_MD5, scsiLun->uuid, md5) < 0)
+ goto cleanup;
virUUIDFormat(md5, uuid_string);
/*
@@ -507,7 +511,8 @@ esxStorageVolLookupByPath(virConnectPtr conn, const char *path)
goto cleanup;
}
- md5_buffer(scsiLun->uuid, strlen(scsiLun->uuid), md5);
+ if (virCryptoHashBuf(VIR_CRYPTO_HASH_MD5, scsiLun->uuid, md5) < 0)
+ goto cleanup;
virUUIDFormat(md5, uuid_string);
volume = virGetStorageVol(conn, poolName, path, uuid_string,
@@ -549,7 +554,8 @@ esxStorageVolLookupByKey(virConnectPtr conn, const char *key)
memset(uuid_string, '\0', sizeof(uuid_string));
memset(md5, '\0', sizeof(md5));
- md5_buffer(scsiLun->uuid, strlen(scsiLun->uuid), md5);
+ if (virCryptoHashBuf(VIR_CRYPTO_HASH_MD5, scsiLun->uuid, md5) < 0)
+ goto cleanup;
virUUIDFormat(md5, uuid_string);
if (STREQ(key, uuid_string)) {
@@ -697,7 +703,8 @@ esxStorageVolGetXMLDesc(virStorageVolPtr volume,
def.name = volume->name;
- md5_buffer(scsiLun->uuid, strlen(scsiLun->uuid), md5);
+ if (virCryptoHashBuf(VIR_CRYPTO_HASH_MD5, scsiLun->uuid, md5) < 0)
+ goto cleanup;
virUUIDFormat(md5, uuid_string);
diff --git a/src/esx/esx_storage_backend_vmfs.c b/src/esx/esx_storage_backend_vmfs.c
index 940e5d1f06..bf5093cf45 100644
--- a/src/esx/esx_storage_backend_vmfs.c
+++ b/src/esx/esx_storage_backend_vmfs.c
@@ -41,6 +41,7 @@
#include "esx_vi.h"
#include "esx_vi_methods.h"
#include "esx_util.h"
+#include "vircrypto.h"
#include "virstring.h"
#define VIR_FROM_THIS VIR_FROM_ESX
@@ -236,8 +237,8 @@ esxStoragePoolLookupByName(virConnectPtr conn,
goto cleanup;
}
- md5_buffer(hostMount->mountInfo->path,
- strlen(hostMount->mountInfo->path), md5);
+ if (virCryptoHashBuf(VIR_CRYPTO_HASH_MD5, hostMount->mountInfo->path, md5) <
0)
+ goto cleanup;
pool = virGetStoragePool(conn, name, md5, &esxStorageBackendVMFS, NULL);
@@ -289,8 +290,8 @@ esxStoragePoolLookupByUUID(virConnectPtr conn,
goto cleanup;
}
- md5_buffer(hostMount->mountInfo->path,
- strlen(hostMount->mountInfo->path), md5);
+ if (virCryptoHashBuf(VIR_CRYPTO_HASH_MD5, hostMount->mountInfo->path, md5)
< 0)
+ goto cleanup;
if (memcmp(uuid, md5, VIR_UUID_BUFLEN) == 0)
break;
--
2.16.1