Blame openssl-pkcs11-0.4.8-improve-code-readability.patch
|
|
889aab1 |
From 1462a0a25286d36cf85acb4bab189ae6cc8eabd0 Mon Sep 17 00:00:00 2001
|
|
|
889aab1 |
From: =?UTF-8?q?Micha=C5=82=20Trojnara?= <Michal.Trojnara@stunnel.org>
|
|
|
889aab1 |
Date: Fri, 31 Aug 2018 08:45:16 +0200
|
|
|
889aab1 |
Subject: [PATCH 14/23] Improved code readability
|
|
|
889aab1 |
|
|
|
889aab1 |
---
|
|
|
889aab1 |
src/p11_slot.c | 13 +++++++------
|
|
|
889aab1 |
1 file changed, 7 insertions(+), 6 deletions(-)
|
|
|
889aab1 |
|
|
|
889aab1 |
diff --git a/src/p11_slot.c b/src/p11_slot.c
|
|
|
889aab1 |
index 94ec378..c5140c1 100644
|
|
|
889aab1 |
--- a/src/p11_slot.c
|
|
|
889aab1 |
+++ b/src/p11_slot.c
|
|
|
889aab1 |
@@ -119,19 +119,20 @@ PKCS11_SLOT *pkcs11_find_token(PKCS11_CTX *ctx, PKCS11_SLOT *slots, unsigned int
|
|
|
889aab1 |
*/
|
|
|
889aab1 |
PKCS11_SLOT *pkcs11_find_next_token(PKCS11_CTX *ctx, PKCS11_SLOT *slots, unsigned int nslots, PKCS11_SLOT *current)
|
|
|
889aab1 |
{
|
|
|
889aab1 |
+ int offset;
|
|
|
889aab1 |
+
|
|
|
889aab1 |
if (slots == NULL)
|
|
|
889aab1 |
return NULL;
|
|
|
889aab1 |
|
|
|
889aab1 |
if (current) {
|
|
|
889aab1 |
- if (slots > current || (current - slots) > nslots)
|
|
|
889aab1 |
+ offset = current + 1 - slots;
|
|
|
889aab1 |
+ if (offset < 1 || (unsigned int)offset >= nslots)
|
|
|
889aab1 |
return NULL;
|
|
|
889aab1 |
-
|
|
|
889aab1 |
- current++;
|
|
|
889aab1 |
- nslots -= (current - slots);
|
|
|
889aab1 |
- slots = current;
|
|
|
889aab1 |
+ } else {
|
|
|
889aab1 |
+ offset = 0;
|
|
|
889aab1 |
}
|
|
|
889aab1 |
|
|
|
889aab1 |
- return pkcs11_find_token(ctx, slots, nslots);
|
|
|
889aab1 |
+ return pkcs11_find_token(ctx, slots+offset, nslots-offset);
|
|
|
889aab1 |
}
|
|
|
889aab1 |
|
|
|
889aab1 |
/*
|
|
|
889aab1 |
--
|
|
|
889aab1 |
2.17.1
|
|
|
889aab1 |
|