Skip to content

Commit

Permalink
Merge pull request #2 from InfoHunter/master
Browse files Browse the repository at this point in the history
Fix CVW-2020-1971
  • Loading branch information
Neo-ZK authored Dec 9, 2020
2 parents bcd6e58 + a493984 commit 0720529
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 80 deletions.
77 changes: 0 additions & 77 deletions appveyor.yml

This file was deleted.

45 changes: 42 additions & 3 deletions crypto/x509v3/v3_genn.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,37 @@ GENERAL_NAME *GENERAL_NAME_dup(GENERAL_NAME *a)
(char *)a);
}

static int edipartyname_cmp(const EDIPARTYNAME *a, const EDIPARTYNAME *b)
{
int res;

if (a == NULL || b == NULL) {
/*
* Shouldn't be possible in a valid GENERAL_NAME, but we handle it
* anyway. OTHERNAME_cmp treats NULL != NULL so we do the same here
*/
return -1;
}
if (a->nameAssigner == NULL && b->nameAssigner != NULL)
return -1;
if (a->nameAssigner != NULL && b->nameAssigner == NULL)
return 1;
/* If we get here then both have nameAssigner set, or both unset */
if (a->nameAssigner != NULL) {
res = ASN1_STRING_cmp(a->nameAssigner, b->nameAssigner);
if (res != 0)
return res;
}
/*
* partyName is required, so these should never be NULL. We treat it in
* the same way as the a == NULL || b == NULL case above
*/
if (a->partyName == NULL || b->partyName == NULL)
return -1;

return ASN1_STRING_cmp(a->partyName, b->partyName);
}

/* Returns 0 if they are equal, != 0 otherwise. */
int GENERAL_NAME_cmp(GENERAL_NAME *a, GENERAL_NAME *b)
{
Expand All @@ -66,8 +97,11 @@ int GENERAL_NAME_cmp(GENERAL_NAME *a, GENERAL_NAME *b)
return -1;
switch (a->type) {
case GEN_X400:
result = ASN1_TYPE_cmp(a->d.x400Address, b->d.x400Address);
break;

case GEN_EDIPARTY:
result = ASN1_TYPE_cmp(a->d.other, b->d.other);
result = edipartyname_cmp(a->d.ediPartyName, b->d.ediPartyName);
break;

case GEN_OTHERNAME:
Expand Down Expand Up @@ -114,8 +148,11 @@ void GENERAL_NAME_set0_value(GENERAL_NAME *a, int type, void *value)
{
switch (type) {
case GEN_X400:
a->d.x400Address = value;
break;

case GEN_EDIPARTY:
a->d.other = value;
a->d.ediPartyName = value;
break;

case GEN_OTHERNAME:
Expand Down Expand Up @@ -149,8 +186,10 @@ void *GENERAL_NAME_get0_value(const GENERAL_NAME *a, int *ptype)
*ptype = a->type;
switch (a->type) {
case GEN_X400:
return a->d.x400Address;

case GEN_EDIPARTY:
return a->d.other;
return a->d.ediPartyName;

case GEN_OTHERNAME:
return a->d.otherName;
Expand Down

0 comments on commit 0720529

Please sign in to comment.