From b1abf22bd04934714bf7f5a544ce65c0bd2118e5 Mon Sep 17 00:00:00 2001 From: Tobias Brunner Date: Mon, 3 Jun 2013 17:30:40 +0200 Subject: [PATCH] Fail DN parsing if OID is unterminated This is the case if the last OID is not followed by a = or if the string starts with a =. --- src/libstrongswan/utils/identification.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/libstrongswan/utils/identification.c b/src/libstrongswan/utils/identification.c index f94a1c8bb..06ec533ea 100644 --- a/src/libstrongswan/utils/identification.c +++ b/src/libstrongswan/utils/identification.c @@ -398,7 +398,7 @@ static status_t atodn(char *src, chunk_t *dn) switch (state) { case SEARCH_OID: - if (*src != ' ' && *src != '/' && *src != ',') + if (*src != ' ' && *src != '/' && *src != ',' && *src != '\0') { oid.ptr = src; oid.len = 1; @@ -502,6 +502,11 @@ static status_t atodn(char *src, chunk_t *dn) } } while (*src++ != '\0'); + if (state == READ_OID) + { /* unterminated OID */ + status = INVALID_ARG; + } + /* build the distinguished name sequence */ { int i; @@ -514,7 +519,6 @@ static status_t atodn(char *src, chunk_t *dn) free(rdns[i].ptr); } } - if (status != SUCCESS) { free(dn->ptr);