[openssh-commits] [openssh] 02/03: upstream: reorder comparison functions to be simpler and faster,

git+noreply at mindrot.org git+noreply at mindrot.org
Wed Nov 11 10:22:23 AEDT 2026


This is an automated email from the git hooks/post-receive script.

djm pushed a commit to branch master
in repository openssh.

commit d00818111509e1d4bab92f6c2ce9446e995b0535
Author: djm at openbsd.org <djm at openbsd.org>
AuthorDate: Mon Nov 9 05:37:58 2026 +0000

    upstream: reorder comparison functions to be simpler and faster,
    
    requested by markus@ and tb@, ok tb@
    
    OpenBSD-Commit-ID: df50feb659c787da02d42caf33628199a8f6ea2d
---
 krl.c | 24 +++++++++---------------
 1 file changed, 9 insertions(+), 15 deletions(-)

diff --git a/krl.c b/krl.c
index 7deac2218..16c457bcd 100644
--- a/krl.c
+++ b/krl.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: krl.c,v 1.67 2026/10/30 05:33:18 djm Exp $ */
+/* $OpenBSD: krl.c,v 1.68 2026/11/09 05:37:58 djm Exp $ */
 /*
  * Copyright (c) 2012 Damien Miller <djm at mindrot.org>
  *
@@ -126,28 +126,22 @@ key_id_cmp(struct revoked_key_id *a, struct revoked_key_id *b)
 static int
 blob_cmp(struct revoked_blob *a, struct revoked_blob *b)
 {
-	int r;
-
-	if (a->len != b->len) {
-		if ((r = memcmp(a->blob, b->blob, MINIMUM(a->len, b->len))) != 0)
-			return r;
+	if (a->len != b->len)
 		return a->len > b->len ? 1 : -1;
-	} else
-		return memcmp(a->blob, b->blob, a->len);
+	if (a->len == 0)
+		return 0;
+	return memcmp(a->blob, b->blob, a->len);
 }
 
 /* NB. the wildcard CA has a NULL, zero-length blob */
 static int
 ca_cmp(struct revoked_certs *a, struct revoked_certs *b)
 {
-	size_t len = MINIMUM(a->ca_blob_len, b->ca_blob_len);
-	int r;
-
-	if (len != 0 && (r = memcmp(a->ca_blob, b->ca_blob, len)) != 0)
-		return r;
-	if (a->ca_blob_len == b->ca_blob_len)
+	if (a->ca_blob_len != b->ca_blob_len)
+		return a->ca_blob_len > b->ca_blob_len ? 1 : -1;
+	if (a->ca_blob_len == 0)
 		return 0;
-	return a->ca_blob_len > b->ca_blob_len ? 1 : -1;
+	return memcmp(a->ca_blob, b->ca_blob, a->ca_blob_len);
 }
 
 struct ssh_krl *

-- 
To stop receiving notification emails like this one, please contact
djm at mindrot.org.


More information about the openssh-commits mailing list