24 Sep 2007 21:11
Another bug in x509_to_ldap
Heyman, Michael <Michael.Heyman <at> sparta.com>
2007-09-24 19:11:28 GMT
2007-09-24 19:11:28 GMT
The x509_to_ldap function would truncate a "normal" name when building
it from ASN.1. A patch that fixes the behavior is below
-Michael Heyman
--- scepldap.c.old Mon Sep 24 15:03:07 2007
+++ scepldap.c Mon Sep 24 15:01:05 2007
<at> <at> -86,19 +86,16 <at> <at>
for (i = X509_NAME_entry_count(name) - 1; i >= 0; i--) {
us =
X509_NAME_ENTRY_get_object(X509_NAME_get_entry(name, i));
as = X509_NAME_ENTRY_get_data(X509_NAME_get_entry(name,
i));
sn = OBJ_nid2sn(OBJ_obj2nid(us));
nl = strlen(sn) + as->length + 1;
- if (dl == 0) { nl += 2; }
- dn = (char *)realloc(dn, dl + nl + 2);
- snprintf(dn + dl, nl + 2, "%s%s=%*.*s",
- (dl == 0) ? "" : ",", us->sn, as->length,
as->length,
+ if (dl) { ++nl; }
+ dn = (char *)realloc(dn, dl + nl + 1);
+ snprintf(dn + dl, nl + 1, "%s%s=%*.*s",
+ (dl) ? "," : "", sn, as->length, as->length,
as->data);
- if (dl == 0)
- dl = nl;
- else
- dl += nl + 1;
+ dl += nl;
(Continue reading)
RSS Feed