From: Kurt Roeckx Date: Thu, 1 May 2014 12:15:54 +0000 (+0200) Subject: Use the smallest of the 2 lengths for the comparison X-Git-Tag: upstream/4.0~90 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=16cb84308aa6e569a553442131d7d2ac8904b4f5;p=platform%2Fupstream%2Flibtasn1.git 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 --- 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 #include "element.h" +#include "minmax.h" #include #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;