>From 634662e4b5a2d46b9c79f702ae19dc426b493a41 Mon Sep 17 00:00:00 2001
From: Kurt Roeckx
Date: Thu, 1 May 2014 14:15:54 +0200
Subject: [PATCH] Use the smallest of the 2 lengths for the comparison
We're sorting 2 strings here based on X.690 section 11.6 and 6.3
---
lib/coding.c | 11 ++++-------
1 file changed, 4 insertions(+), 7 deletions(-)
diff --git a/lib/coding.c b/lib/coding.c
index 2a3106d..e78e9cd 100644
--- a/lib/coding.c
+++ b/lib/coding.c
@@ -30,6 +30,7 @@
#include "parser_aux.h"
#include
#include "element.h"
+#include "minmax.h"
#include
#define MAX_TAG_LEN 16
@@ -855,7 +856,7 @@ _asn1_ordering_set_of (unsigned char *der, int der_len, asn1_node node)
struct vet *first, *last, *p_vet, *p2_vet;
asn1_node p;
unsigned char *temp, class;
- unsigned long k, max;
+ unsigned long k, length;
int err;
counter = 0;
@@ -928,13 +929,9 @@ _asn1_ordering_set_of (unsigned char *der, int der_len, asn1_node node)
counter = 0;
while (p2_vet)
{
- if ((p_vet->end - counter) > (p2_vet->end - p_vet->end))
- max = p_vet->end - counter;
- else
- max = p2_vet->end - p_vet->end;
-
+ length = MIN(p_vet->end - counter, p2_vet->end - p_vet->end);
change = -1;
- for (k = 0; k < max; k++)
+ for (k = 0; k < length; k++)
if (der[counter + k] > der[p_vet->end + k])
{
change = 1;
--
1.9.2