From nobody Wed May 14 06:43:21 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 152605383486546.819202211121706; Fri, 11 May 2018 08:50:34 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0386B30001E1; Fri, 11 May 2018 15:50:33 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B4C3860920; Fri, 11 May 2018 15:50:32 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 6694B180B5B1; Fri, 11 May 2018 15:50:32 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w4BFoM9l017728 for ; Fri, 11 May 2018 11:50:22 -0400 Received: by smtp.corp.redhat.com (Postfix) id 015C183B79; Fri, 11 May 2018 15:50:22 +0000 (UTC) Received: from icr.brq.redhat.com (unknown [10.43.2.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4B15F83B7A for ; Fri, 11 May 2018 15:50:21 +0000 (UTC) From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Date: Fri, 11 May 2018 17:50:13 +0200 Message-Id: <096fa54847cf766078f60dd4496408f164a36387.1526053739.git.jtomko@redhat.com> In-Reply-To: References: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 3/5] esx: use virCryptoHashBuf X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Fri, 11 May 2018 15:50:34 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Instead of using md5_buffer from gnulib directly. Signed-off-by: J=C3=A1n Tomko --- 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" =20 #define VIR_FROM_THIS VIR_FROM_ESX @@ -152,7 +153,8 @@ esxNetworkLookupByUUID(virConnectPtr conn, const unsign= ed char *uuid) =20 for (hostVirtualSwitch =3D hostVirtualSwitchList; hostVirtualSwitch; hostVirtualSwitch =3D hostVirtualSwitch->_next) { - md5_buffer(hostVirtualSwitch->key, strlen(hostVirtualSwitch->key),= md5); + if (virCryptoHashBuf(VIR_CRYPTO_HASH_MD5, hostVirtualSwitch->key, = md5) < 0) + goto cleanup; =20 if (memcmp(uuid, md5, VIR_UUID_BUFLEN) =3D=3D 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 conside= red * 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; =20 network =3D virGetNetwork(conn, hostVirtualSwitch->name, md5); =20 @@ -464,7 +467,8 @@ esxNetworkDefineXML(virConnectPtr conn, const char *xml) goto cleanup; } =20 - md5_buffer(hostVirtualSwitch->key, strlen(hostVirtualSwitch->key), md5= ); + if (virCryptoHashBuf(VIR_CRYPTO_HASH_MD5, hostVirtualSwitch->key, md5)= < 0) + goto cleanup; =20 network =3D virGetNetwork(conn, hostVirtualSwitch->name, md5); =20 @@ -655,7 +659,8 @@ esxNetworkGetXMLDesc(virNetworkPtr network_, unsigned i= nt flags) goto cleanup; } =20 - md5_buffer(hostVirtualSwitch->key, strlen(hostVirtualSwitch->key), def= ->uuid); + if (virCryptoHashBuf(VIR_CRYPTO_HASH_MD5, hostVirtualSwitch->key, def-= >uuid) < 0) + goto cleanup; =20 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_back= end_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" =20 #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; =20 pool =3D virGetStoragePool(conn, name, md5, &esxStorageBackendISCSI, N= ULL); =20 @@ -218,7 +220,8 @@ esxStoragePoolLookupByUUID(virConnectPtr conn, =20 for (target =3D hostInternetScsiHba->configuredStaticTarget; target; target =3D target->_next) { - md5_buffer(target->iScsiName, strlen(target->iScsiName), md5); + if (virCryptoHashBuf(VIR_CRYPTO_HASH_MD5, target->iScsiName, md5) = < 0) + goto cleanup; =20 if (memcmp(uuid, md5, VIR_UUID_BUFLEN) =3D=3D 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); =20 /* @@ -507,7 +511,8 @@ esxStorageVolLookupByPath(virConnectPtr conn, const cha= r *path) goto cleanup; } =20 - md5_buffer(scsiLun->uuid, strlen(scsiLun->uuid), md5); + if (virCryptoHashBuf(VIR_CRYPTO_HASH_MD5, scsiLun->uuid, md5) = < 0) + goto cleanup; virUUIDFormat(md5, uuid_string); =20 volume =3D 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)); =20 - md5_buffer(scsiLun->uuid, strlen(scsiLun->uuid), md5); + if (virCryptoHashBuf(VIR_CRYPTO_HASH_MD5, scsiLun->uuid, md5) < 0) + goto cleanup; virUUIDFormat(md5, uuid_string); =20 if (STREQ(key, uuid_string)) { @@ -697,7 +703,8 @@ esxStorageVolGetXMLDesc(virStorageVolPtr volume, =20 def.name =3D volume->name; =20 - md5_buffer(scsiLun->uuid, strlen(scsiLun->uuid), md5); + if (virCryptoHashBuf(VIR_CRYPTO_HASH_MD5, scsiLun->uuid, md5) < 0) + goto cleanup; =20 virUUIDFormat(md5, uuid_string); =20 diff --git a/src/esx/esx_storage_backend_vmfs.c b/src/esx/esx_storage_backe= nd_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" =20 #define VIR_FROM_THIS VIR_FROM_ESX @@ -236,8 +237,8 @@ esxStoragePoolLookupByName(virConnectPtr conn, goto cleanup; } =20 - md5_buffer(hostMount->mountInfo->path, - strlen(hostMount->mountInfo->path), md5); + if (virCryptoHashBuf(VIR_CRYPTO_HASH_MD5, hostMount->mountInfo->path, = md5) < 0) + goto cleanup; =20 pool =3D virGetStoragePool(conn, name, md5, &esxStorageBackendVMFS, NU= LL); =20 @@ -289,8 +290,8 @@ esxStoragePoolLookupByUUID(virConnectPtr conn, goto cleanup; } =20 - md5_buffer(hostMount->mountInfo->path, - strlen(hostMount->mountInfo->path), md5); + if (virCryptoHashBuf(VIR_CRYPTO_HASH_MD5, hostMount->mountInfo->pa= th, md5) < 0) + goto cleanup; =20 if (memcmp(uuid, md5, VIR_UUID_BUFLEN) =3D=3D 0) break; --=20 2.16.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list