48 lines
1.8 KiB
Diff
48 lines
1.8 KiB
Diff
|
|
From ca6f8348075be1839e87fa826a2719127ec64d41 Mon Sep 17 00:00:00 2001
|
||
|
|
From: dinglimin <dinglimin@cmss.chinamobile.com>
|
||
|
|
Date: Mon, 2 Sep 2024 17:40:40 +0800
|
||
|
|
Subject: [PATCH] crypto/block-luks: make range overlap check more readable
|
||
|
|
MIME-Version: 1.0
|
||
|
|
Content-Type: text/plain; charset=UTF-8
|
||
|
|
Content-Transfer-Encoding: 8bit
|
||
|
|
|
||
|
|
cheery-pick from 7cd9b9d476e729808f3c9b82a12f51a39673d5cb
|
||
|
|
|
||
|
|
use ranges_overlap() instead of open-coding the overlap check to improve the readability of the code.
|
||
|
|
|
||
|
|
Signed-off-by: Yao Xingtao <yaoxt.fnst@fujitsu.com>
|
||
|
|
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
|
||
|
|
Tested-by: Philippe Mathieu-Daudé <philmd@linaro.org>
|
||
|
|
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
|
||
|
|
Message-ID: <20240722040742.11513-12-yaoxt.fnst@fujitsu.com>
|
||
|
|
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
|
||
|
|
Signed-off-by: dinglimin <dinglimin@cmss.chinamobile.com>
|
||
|
|
---
|
||
|
|
crypto/block-luks.c | 3 ++-
|
||
|
|
1 file changed, 2 insertions(+), 1 deletion(-)
|
||
|
|
|
||
|
|
diff --git a/crypto/block-luks.c b/crypto/block-luks.c
|
||
|
|
index fe8f04ffb2..2648719337 100644
|
||
|
|
--- a/crypto/block-luks.c
|
||
|
|
+++ b/crypto/block-luks.c
|
||
|
|
@@ -33,6 +33,7 @@
|
||
|
|
|
||
|
|
#include "qemu/coroutine.h"
|
||
|
|
#include "qemu/bitmap.h"
|
||
|
|
+#include "qemu/range.h"
|
||
|
|
|
||
|
|
/*
|
||
|
|
* Reference for the LUKS format implemented here is
|
||
|
|
@@ -591,7 +592,7 @@ qcrypto_block_luks_check_header(const QCryptoBlockLUKS *luks, Error **errp)
|
||
|
|
header_sectors,
|
||
|
|
slot2->stripes);
|
||
|
|
|
||
|
|
- if (start1 + len1 > start2 && start2 + len2 > start1) {
|
||
|
|
+ if (ranges_overlap(start1, len1, start2, len2)) {
|
||
|
|
error_setg(errp,
|
||
|
|
"Keyslots %zu and %zu are overlapping in the header",
|
||
|
|
i, j);
|
||
|
|
--
|
||
|
|
2.41.0.windows.1
|
||
|
|
|