From 2ce0f82c5d09c348d2f41bad9bc6d9ae0e9b08d3 Mon Sep 17 00:00:00 2001 From: Kurt Roeckx Date: Sun, 20 Apr 2014 16:50:00 +0200 Subject: [PATCH] Call ordering functions with the right length We're going to insert the length of the set and at this point are going to order it. But we called it with the wrong length. Also updates the check to only do it when the buffer isn't to small. --- lib/coding.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/coding.c b/lib/coding.c index e640c0b..052c947 100644 --- a/lib/coding.c +++ b/lib/coding.c @@ -1167,7 +1167,7 @@ asn1_der_coding (asn1_node element, const char *name, void *ider, int *len, len2 = _asn1_strtol (p->value, NULL, 10); _asn1_set_value (p, NULL, 0); if ((type_field (p->type) == ASN1_ETYPE_SET) && (max_len >= 0)) - _asn1_ordering_set (der + len2, max_len - len2, p); + _asn1_ordering_set (der + len2, counter - len2, p); asn1_length_der (counter - len2, temp, &len3); max_len -= len3; if (max_len >= 0) @@ -1207,7 +1207,7 @@ asn1_der_coding (asn1_node element, const char *name, void *ider, int *len, len2 = _asn1_strtol (p->value, NULL, 10); _asn1_set_value (p, NULL, 0); if ((type_field (p->type) == ASN1_ETYPE_SET_OF) - && (max_len - len2 > 0)) + && (counter - len2 > 0) && (max_len >= 0)) { _asn1_ordering_set_of (der + len2, max_len - len2, p); } -- 2.7.4