asn1: Fix some of the primitive comparators
The comparators for BIT STRING and unconstrained INTEGER need help too.
This commit is contained in:
@@ -36,20 +36,44 @@
|
||||
int
|
||||
der_heim_oid_cmp(const heim_oid *p, const heim_oid *q)
|
||||
{
|
||||
if (p->length != q->length)
|
||||
return (int)(p->length - q->length);
|
||||
return memcmp(p->components,
|
||||
q->components,
|
||||
p->length * sizeof(*p->components));
|
||||
int c;
|
||||
|
||||
if (p->length == q->length)
|
||||
return memcmp(p->components,
|
||||
q->components,
|
||||
p->length * sizeof(*p->components));
|
||||
if (p->length < q->length) {
|
||||
c = memcmp(p->components,
|
||||
q->components,
|
||||
p->length * sizeof(*p->components));
|
||||
if (c == 0)
|
||||
return -1;
|
||||
return c;
|
||||
}
|
||||
c = memcmp(p->components,
|
||||
q->components,
|
||||
q->length * sizeof(*p->components));
|
||||
if (c == 0)
|
||||
return 1;
|
||||
return c;
|
||||
}
|
||||
|
||||
int
|
||||
der_heim_octet_string_cmp(const heim_octet_string *p,
|
||||
const heim_octet_string *q)
|
||||
{
|
||||
if (p->length != q->length)
|
||||
return (int)(p->length - q->length);
|
||||
return memcmp(p->data, q->data, p->length);
|
||||
int c;
|
||||
|
||||
if (p->length == q->length)
|
||||
return memcmp(p->data, q->data, p->length);
|
||||
if (p->length < q->length) {
|
||||
if ((c = memcmp(p->data, q->data, p->length)) == 0)
|
||||
return -1;
|
||||
return c;
|
||||
}
|
||||
if ((c = memcmp(p->data, q->data, q->length)) == 0)
|
||||
return 1;
|
||||
return c;
|
||||
}
|
||||
|
||||
int
|
||||
@@ -102,16 +126,34 @@ der_heim_integer_cmp(const heim_integer *p,
|
||||
int
|
||||
der_heim_bmp_string_cmp(const heim_bmp_string *p, const heim_bmp_string *q)
|
||||
{
|
||||
if (p->length != q->length)
|
||||
return (int)(p->length - q->length);
|
||||
return memcmp(p->data, q->data, q->length * sizeof(q->data[0]));
|
||||
int c;
|
||||
|
||||
if (p->length == q->length)
|
||||
return memcmp(p->data, q->data, p->length * sizeof(q->data[0]));
|
||||
if (p->length < q->length) {
|
||||
if ((c = memcmp(p->data, q->data, p->length * sizeof(q->data[0]))) == 0)
|
||||
return -1;
|
||||
return c;
|
||||
}
|
||||
if ((c = memcmp(p->data, q->data, q->length * sizeof(q->data[0]))) == 0)
|
||||
return 1;
|
||||
return c;
|
||||
}
|
||||
|
||||
int
|
||||
der_heim_universal_string_cmp(const heim_universal_string *p,
|
||||
const heim_universal_string *q)
|
||||
{
|
||||
if (p->length != q->length)
|
||||
return (int)(p->length - q->length);
|
||||
return memcmp(p->data, q->data, q->length * sizeof(q->data[0]));
|
||||
int c;
|
||||
|
||||
if (p->length == q->length)
|
||||
return memcmp(p->data, q->data, p->length * sizeof(q->data[0]));
|
||||
if (p->length < q->length) {
|
||||
if ((c = memcmp(p->data, q->data, p->length * sizeof(q->data[0]))) == 0)
|
||||
return -1;
|
||||
return c;
|
||||
}
|
||||
if ((c = memcmp(p->data, q->data, q->length * sizeof(q->data[0]))) == 0)
|
||||
return 1;
|
||||
return c;
|
||||
}
|
||||
|
Reference in New Issue
Block a user