提交 787ebcaf 编写于 作者: D Dr. Stephen Henson

Update macros.

Use TLS_MAX_SIGALGCNT for the maximum number of entries in the
signature algorithms array.

Use TLS_MAX_SIGSTRING_LEN for the maxiumum length of each signature
component instead of a magic number.
Reviewed-by: NRichard Levitte <levitte@openssl.org>
Reviewed-by: NMatt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/2301)
上级 91410d40
...@@ -1715,11 +1715,12 @@ int SSL_get_shared_sigalgs(SSL *s, int idx, ...@@ -1715,11 +1715,12 @@ int SSL_get_shared_sigalgs(SSL *s, int idx,
return (int)s->cert->shared_sigalgslen; return (int)s->cert->shared_sigalgslen;
} }
#define MAX_SIGALGLEN (TLSEXT_hash_num * TLSEXT_signature_num * 2) /* Maximum possible number of unique entries in sigalgs array */
#define TLS_MAX_SIGALGCNT (OSSL_NELEM(sigalg_lookup_tbl) * 2)
typedef struct { typedef struct {
size_t sigalgcnt; size_t sigalgcnt;
int sigalgs[MAX_SIGALGLEN]; int sigalgs[TLS_MAX_SIGALGCNT];
} sig_cb_st; } sig_cb_st;
static void get_sigorhash(int *psig, int *phash, const char *str) static void get_sigorhash(int *psig, int *phash, const char *str)
...@@ -1738,16 +1739,18 @@ static void get_sigorhash(int *psig, int *phash, const char *str) ...@@ -1738,16 +1739,18 @@ static void get_sigorhash(int *psig, int *phash, const char *str)
*phash = OBJ_ln2nid(str); *phash = OBJ_ln2nid(str);
} }
} }
/* Maximum length of a signature algorithm string component */
#define TLS_MAX_SIGSTRING_LEN 40
static int sig_cb(const char *elem, int len, void *arg) static int sig_cb(const char *elem, int len, void *arg)
{ {
sig_cb_st *sarg = arg; sig_cb_st *sarg = arg;
size_t i; size_t i;
char etmp[40], *p; char etmp[TLS_MAX_SIGSTRING_LEN], *p;
int sig_alg = NID_undef, hash_alg = NID_undef; int sig_alg = NID_undef, hash_alg = NID_undef;
if (elem == NULL) if (elem == NULL)
return 0; return 0;
if (sarg->sigalgcnt == MAX_SIGALGLEN) if (sarg->sigalgcnt == TLS_MAX_SIGALGCNT)
return 0; return 0;
if (len > (int)(sizeof(etmp) - 1)) if (len > (int)(sizeof(etmp) - 1))
return 0; return 0;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册