-
Notifications
You must be signed in to change notification settings - Fork 122
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
184 additions
and
140 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -54,8 +54,8 @@ | |
* ([email protected]). This product includes software written by Tim | ||
* Hudson ([email protected]). */ | ||
|
||
#include <stdio.h> | ||
|
||
#include <assert.h> | ||
#include <limits.h> | ||
#include <string.h> | ||
|
||
#include <openssl/digest.h> | ||
|
@@ -171,8 +171,12 @@ int X509_PURPOSE_get_by_sname(const char *sname) { | |
} | ||
|
||
int X509_PURPOSE_get_by_id(int purpose) { | ||
if (purpose >= X509_PURPOSE_MIN && purpose <= X509_PURPOSE_MAX) { | ||
return purpose - X509_PURPOSE_MIN; | ||
for (size_t i = 0; i <OPENSSL_ARRAY_SIZE(xstandard); i++) { | ||
if (xstandard[i].purpose == purpose) { | ||
OPENSSL_STATIC_ASSERT(OPENSSL_ARRAY_SIZE(xstandard) <= INT_MAX, | ||
indices_must_fit_in_int); | ||
return (int)i; | ||
} | ||
} | ||
return -1; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -54,6 +54,9 @@ | |
* ([email protected]). This product includes software written by Tim | ||
* Hudson ([email protected]). */ | ||
|
||
#include <assert.h> | ||
#include <limits.h> | ||
|
||
#include <openssl/err.h> | ||
#include <openssl/mem.h> | ||
#include <openssl/obj.h> | ||
|
@@ -69,10 +72,6 @@ static int trust_compat(const X509_TRUST *trust, X509 *x, int flags); | |
|
||
static int obj_trust(int id, X509 *x, int flags); | ||
|
||
// WARNING: the following table should be kept in order of trust and without | ||
// any gaps so we can just subtract the minimum trust value to get an index | ||
// into the table | ||
|
||
static const X509_TRUST trstandard[] = { | ||
{X509_TRUST_COMPAT, 0, trust_compat, (char *)"compatible", 0, NULL}, | ||
{X509_TRUST_SSL_CLIENT, 0, trust_1oidany, (char *)"SSL Client", | ||
|
@@ -122,8 +121,12 @@ const X509_TRUST *X509_TRUST_get0(int idx) { | |
} | ||
|
||
int X509_TRUST_get_by_id(int id) { | ||
if (id >= X509_TRUST_MIN && id <= X509_TRUST_MAX) { | ||
return id - X509_TRUST_MIN; | ||
for (size_t i = 0; i < OPENSSL_ARRAY_SIZE(trstandard); i++) { | ||
if (trstandard[i].trust == id) { | ||
OPENSSL_STATIC_ASSERT(OPENSSL_ARRAY_SIZE(trstandard) <= INT_MAX, | ||
indices_must_fit_in_int); | ||
return (int)i; | ||
} | ||
} | ||
return -1; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.