summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Lidén Borell <samuel@slbdata.se>2011-09-05 19:22:17 (GMT)
committerSamuel Lidén Borell <samuel@slbdata.se>2011-09-05 19:22:17 (GMT)
commitb8322a15364dcac95721f56c2fd38eb63c82e582 (patch)
tree2486d824a9035900e46e3539f475e42aa43d2015
parente0a1a9d739b6dd6ed50ae99dff79b4dc1477546c (diff)
downloadfribid-b8322a15364dcac95721f56c2fd38eb63c82e582.zip
fribid-b8322a15364dcac95721f56c2fd38eb63c82e582.tar.gz
fribid-b8322a15364dcac95721f56c2fd38eb63c82e582.tar.bz2
Ignore leading/trailing whitespace in SubjectDN
-rw-r--r--client/certutil.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/client/certutil.c b/client/certutil.c
index 8306027..879d64a 100644
--- a/client/certutil.c
+++ b/client/certutil.c
@@ -107,6 +107,9 @@ X509_NAME *certutil_parse_dn(const char *s, bool fullDN) {
ASN1_OBJECT *obj = NULL;
while (*s != '\0') {
+ // Ignore leading whitespace (this includes whitespace after a comma)
+ while (g_ascii_isspace(*s)) s++;
+
// Parse attribute
size_t nameLength = strcspn(s, ",+=");
if (s[nameLength] != '=') goto error;
@@ -116,6 +119,10 @@ X509_NAME *certutil_parse_dn(const char *s, bool fullDN) {
size_t valueLength = strcspn(value, "+,");
if (value[valueLength] == '+') goto error; // Not supported
+ // Ignore trailing whitespace
+ const char *end = &s[nameLength+1+valueLength];
+ while (g_ascii_isspace(value[valueLength-1])) valueLength--;
+
// Parse attribute name
char *field = g_strndup(s, nameLength);
int nid;
@@ -136,7 +143,7 @@ X509_NAME *certutil_parse_dn(const char *s, bool fullDN) {
obj = NULL;
// Go to next attribute
- s += nameLength+1+valueLength;
+ s = end;
if (*s == ',') s++;
}