Remove useless code

RT#4081

Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
(cherry picked from commit 070c23325a)
This commit is contained in:
Alessandro Ghedini 2015-10-08 22:00:27 +02:00 committed by Richard Levitte
parent a5524e534b
commit 200c8ed4f5
13 changed files with 6 additions and 45 deletions

View file

@ -119,9 +119,6 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#if !defined(OPENSSL_SYSNAME_WIN32) && !defined(NETWARE_CLIB)
# include <strings.h>
#endif
#include <sys/types.h> #include <sys/types.h>
#include <ctype.h> #include <ctype.h>
#include <errno.h> #include <errno.h>

View file

@ -99,25 +99,19 @@
#undef PROG #undef PROG
#define PROG ca_main #define PROG ca_main
#define BASE_SECTION "ca" #define BASE_SECTION "ca"
#define CONFIG_FILE "openssl.cnf" #define CONFIG_FILE "openssl.cnf"
#define ENV_DEFAULT_CA "default_ca" #define ENV_DEFAULT_CA "default_ca"
#define STRING_MASK "string_mask" #define STRING_MASK "string_mask"
#define UTF8_IN "utf8" #define UTF8_IN "utf8"
#define ENV_DIR "dir"
#define ENV_CERTS "certs"
#define ENV_CRL_DIR "crl_dir"
#define ENV_CA_DB "CA_DB"
#define ENV_NEW_CERTS_DIR "new_certs_dir" #define ENV_NEW_CERTS_DIR "new_certs_dir"
#define ENV_CERTIFICATE "certificate" #define ENV_CERTIFICATE "certificate"
#define ENV_SERIAL "serial" #define ENV_SERIAL "serial"
#define ENV_CRLNUMBER "crlnumber" #define ENV_CRLNUMBER "crlnumber"
#define ENV_CRL "crl"
#define ENV_PRIVATE_KEY "private_key" #define ENV_PRIVATE_KEY "private_key"
#define ENV_RANDFILE "RANDFILE"
#define ENV_DEFAULT_DAYS "default_days" #define ENV_DEFAULT_DAYS "default_days"
#define ENV_DEFAULT_STARTDATE "default_startdate" #define ENV_DEFAULT_STARTDATE "default_startdate"
#define ENV_DEFAULT_ENDDATE "default_enddate" #define ENV_DEFAULT_ENDDATE "default_enddate"

View file

@ -413,8 +413,6 @@ int MAIN(int argc, char **argv)
} }
if (check) { if (check) {
if (group == NULL)
BIO_printf(bio_err, "no elliptic curve parameters\n");
BIO_printf(bio_err, "checking elliptic curve parameters: "); BIO_printf(bio_err, "checking elliptic curve parameters: ");
if (!EC_GROUP_check(group, NULL)) { if (!EC_GROUP_check(group, NULL)) {
BIO_printf(bio_err, "failed\n"); BIO_printf(bio_err, "failed\n");

View file

@ -99,8 +99,6 @@ static void identity(char *ptr)
static int append_buf(char **buf, const char *s, int *size, int step) static int append_buf(char **buf, const char *s, int *size, int step)
{ {
int l = strlen(s);
if (*buf == NULL) { if (*buf == NULL) {
*size = step; *size = step;
*buf = OPENSSL_malloc(*size); *buf = OPENSSL_malloc(*size);
@ -109,9 +107,6 @@ static int append_buf(char **buf, const char *s, int *size, int step)
**buf = '\0'; **buf = '\0';
} }
if (**buf != '\0')
l += 2; /* ", " */
if (strlen(*buf) + strlen(s) >= (unsigned int)*size) { if (strlen(*buf) + strlen(s) >= (unsigned int)*size) {
*size += step; *size += step;
*buf = OPENSSL_realloc(*buf, *size); *buf = OPENSSL_realloc(*buf, *size);

View file

@ -104,7 +104,6 @@ int BIO_dump_indent_cb(int (*cb) (const void *data, size_t len, void *u),
if ((rows * dump_width) < len) if ((rows * dump_width) < len)
rows++; rows++;
for (i = 0; i < rows; i++) { for (i = 0; i < rows; i++) {
buf[0] = '\0'; /* start with empty string */
BUF_strlcpy(buf, str, sizeof buf); BUF_strlcpy(buf, str, sizeof buf);
BIO_snprintf(tmp, sizeof tmp, "%04x - ", i * dump_width); BIO_snprintf(tmp, sizeof tmp, "%04x - ", i * dump_width);
BUF_strlcat(buf, tmp, sizeof buf); BUF_strlcat(buf, tmp, sizeof buf);

View file

@ -112,16 +112,8 @@ int DSA_generate_parameters_ex(DSA *ret, int bits,
} }
# endif # endif
else { else {
const EVP_MD *evpmd; const EVP_MD *evpmd = bits >= 2048 ? EVP_sha256() : EVP_sha1();
size_t qbits = bits >= 2048 ? 256 : 160; size_t qbits = EVP_MD_size(evpmd) * 8;
if (bits >= 2048) {
qbits = 256;
evpmd = EVP_sha256();
} else {
qbits = 160;
evpmd = EVP_sha1();
}
return dsa_builtin_paramgen(ret, bits, qbits, evpmd, return dsa_builtin_paramgen(ret, bits, qbits, evpmd,
seed_in, seed_len, NULL, counter_ret, seed_in, seed_len, NULL, counter_ret,

View file

@ -246,12 +246,6 @@ int OCSP_parse_url(char *url, char **phost, char **pport, char **ppath,
if ((p = strchr(p, ':'))) { if ((p = strchr(p, ':'))) {
*p = 0; *p = 0;
port = p + 1; port = p + 1;
} else {
/* Not found: set default port */
if (*pssl)
port = "443";
else
port = "80";
} }
*pport = BUF_strdup(port); *pport = BUF_strdup(port);

View file

@ -212,8 +212,7 @@ int OCSP_RESPONSE_print(BIO *bp, OCSP_RESPONSE *o, unsigned long flags)
return 1; return 1;
} }
i = ASN1_STRING_length(rb->response); if ((br = OCSP_response_get1_basic(o)) == NULL)
if (!(br = OCSP_response_get1_basic(o)))
goto err; goto err;
rd = br->tbsResponseData; rd = br->tbsResponseData;
l = ASN1_INTEGER_get(rd->version); l = ASN1_INTEGER_get(rd->version);

View file

@ -624,13 +624,11 @@ static int do_PVK_header(const unsigned char **in, unsigned int length,
PEMerr(PEM_F_DO_PVK_HEADER, PEM_R_PVK_TOO_SHORT); PEMerr(PEM_F_DO_PVK_HEADER, PEM_R_PVK_TOO_SHORT);
return 0; return 0;
} }
length -= 20;
} else { } else {
if (length < 24) { if (length < 24) {
PEMerr(PEM_F_DO_PVK_HEADER, PEM_R_PVK_TOO_SHORT); PEMerr(PEM_F_DO_PVK_HEADER, PEM_R_PVK_TOO_SHORT);
return 0; return 0;
} }
length -= 24;
pvk_magic = read_ledword(&p); pvk_magic = read_ledword(&p);
if (pvk_magic != MS_PVKMAGIC) { if (pvk_magic != MS_PVKMAGIC) {
PEMerr(PEM_F_DO_PVK_HEADER, PEM_R_BAD_MAGIC_NUMBER); PEMerr(PEM_F_DO_PVK_HEADER, PEM_R_BAD_MAGIC_NUMBER);

View file

@ -1156,7 +1156,6 @@ PKCS7_ISSUER_AND_SERIAL *PKCS7_get_issuer_and_serial(PKCS7 *p7, int idx)
rsk = p7->d.signed_and_enveloped->recipientinfo; rsk = p7->d.signed_and_enveloped->recipientinfo;
if (rsk == NULL) if (rsk == NULL)
return NULL; return NULL;
ri = sk_PKCS7_RECIP_INFO_value(rsk, 0);
if (sk_PKCS7_RECIP_INFO_num(rsk) <= idx) if (sk_PKCS7_RECIP_INFO_num(rsk) <= idx)
return (NULL); return (NULL);
ri = sk_PKCS7_RECIP_INFO_value(rsk, idx); ri = sk_PKCS7_RECIP_INFO_value(rsk, idx);

View file

@ -523,8 +523,6 @@ STACK_OF(X509_CRL) *X509_STORE_get1_crls(X509_STORE_CTX *ctx, X509_NAME *nm)
X509_OBJECT *obj, xobj; X509_OBJECT *obj, xobj;
sk = sk_X509_CRL_new_null(); sk = sk_X509_CRL_new_null();
CRYPTO_w_lock(CRYPTO_LOCK_X509_STORE); CRYPTO_w_lock(CRYPTO_LOCK_X509_STORE);
/* Check cache first */
idx = x509_object_idx_cnt(ctx->ctx->objs, X509_LU_CRL, nm, &cnt);
/* /*
* Always do lookup to possibly add new CRLs to cache * Always do lookup to possibly add new CRLs to cache

View file

@ -3218,7 +3218,6 @@ int ssl3_send_client_certificate(SSL *s)
* If we get an error, we need to ssl->rwstate=SSL_X509_LOOKUP; * If we get an error, we need to ssl->rwstate=SSL_X509_LOOKUP;
* return(-1); We then get retied later * return(-1); We then get retied later
*/ */
i = 0;
i = ssl_do_client_cert_cb(s, &x509, &pkey); i = ssl_do_client_cert_cb(s, &x509, &pkey);
if (i < 0) { if (i < 0) {
s->rwstate = SSL_X509_LOOKUP; s->rwstate = SSL_X509_LOOKUP;

View file

@ -383,7 +383,6 @@ int ssl3_accept(SSL *s)
*/ */
if (al != TLS1_AD_UNKNOWN_PSK_IDENTITY) if (al != TLS1_AD_UNKNOWN_PSK_IDENTITY)
SSLerr(SSL_F_SSL3_ACCEPT, SSL_R_CLIENTHELLO_TLSEXT); SSLerr(SSL_F_SSL3_ACCEPT, SSL_R_CLIENTHELLO_TLSEXT);
ret = SSL_TLSEXT_ERR_ALERT_FATAL;
ret = -1; ret = -1;
s->state = SSL_ST_ERR; s->state = SSL_ST_ERR;
goto end; goto end;