summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKurt Roeckx <kurt@roeckx.be>2014-05-01 14:15:54 +0200
committerNikos Mavrogiannopoulos <nmav@gnutls.org>2014-05-01 14:28:21 +0200
commit16cb84308aa6e569a553442131d7d2ac8904b4f5 (patch)
tree12ee5a949bfb4f74ad08a53c96d3430564d3a40b
parent47364430f0ec21e2e4a8923a2fc6320ddbf42887 (diff)
downloadlibtasn1-16cb84308aa6e569a553442131d7d2ac8904b4f5.tar.gz
libtasn1-16cb84308aa6e569a553442131d7d2ac8904b4f5.tar.bz2
libtasn1-16cb84308aa6e569a553442131d7d2ac8904b4f5.zip
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
-rw-r--r--lib/coding.c11
1 files changed, 4 insertions, 7 deletions
diff --git a/lib/coding.c b/lib/coding.c
index 6fb7c05..e4eb060 100644
--- a/lib/coding.c
+++ b/lib/coding.c
@@ -30,6 +30,7 @@
#include "parser_aux.h"
#include <gstr.h>
#include "element.h"
+#include "minmax.h"
#include <structure.h>
#define MAX_TAG_LEN 16
@@ -850,7 +851,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;
@@ -923,13 +924,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;