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 =.
This commit is contained in:
Tobias Brunner
2013-06-11 11:03:12 +02:00
parent f00c350688
commit b1abf22bd0
+6 -2
View File
@@ -398,7 +398,7 @@ static status_t atodn(char *src, chunk_t *dn)
switch (state) switch (state)
{ {
case SEARCH_OID: case SEARCH_OID:
if (*src != ' ' && *src != '/' && *src != ',') if (*src != ' ' && *src != '/' && *src != ',' && *src != '\0')
{ {
oid.ptr = src; oid.ptr = src;
oid.len = 1; oid.len = 1;
@@ -502,6 +502,11 @@ static status_t atodn(char *src, chunk_t *dn)
} }
} while (*src++ != '\0'); } while (*src++ != '\0');
if (state == READ_OID)
{ /* unterminated OID */
status = INVALID_ARG;
}
/* build the distinguished name sequence */ /* build the distinguished name sequence */
{ {
int i; int i;
@@ -514,7 +519,6 @@ static status_t atodn(char *src, chunk_t *dn)
free(rdns[i].ptr); free(rdns[i].ptr);
} }
} }
if (status != SUCCESS) if (status != SUCCESS)
{ {
free(dn->ptr); free(dn->ptr);