int a2i_ASN1_ENUMERATED(BIO *bp, ASN1_ENUMERATED *bs, char *buf, int size)
{
- int ret = 0;
int i, j, k, m, n, again, bufsize;
unsigned char *s = NULL, *sp;
unsigned char *bufp;
bufsize = BIO_gets(bp, buf, size);
for (;;) {
if (bufsize < 1)
- goto err_sl;
+ goto err;
i = bufsize;
if (buf[i - 1] == '\n')
buf[--i] = '\0';
if (i == 0)
- goto err_sl;
+ goto err;
if (buf[i - 1] == '\r')
buf[--i] = '\0';
if (i == 0)
- goto err_sl;
+ goto err;
again = (buf[i - 1] == '\\');
for (j = 0; j < i; j++) {
* We have now cleared all the crap off the end of the line
*/
if (i < 2)
- goto err_sl;
+ goto err;
bufp = (unsigned char *)buf;
if (first) {
i -= again;
if (i % 2 != 0) {
ASN1err(ASN1_F_A2I_ASN1_ENUMERATED, ASN1_R_ODD_NUMBER_OF_CHARS);
- goto err;
+ return 0;
}
i /= 2;
if (num + i > slen) {
if (sp == NULL) {
ASN1err(ASN1_F_A2I_ASN1_ENUMERATED, ERR_R_MALLOC_FAILURE);
OPENSSL_free(s);
- goto err;
+ return 0;
}
s = sp;
slen = num + i * 2;
else {
ASN1err(ASN1_F_A2I_ASN1_ENUMERATED,
ASN1_R_NON_HEX_CHARACTERS);
- goto err;
+ return 0;
}
s[num + j] <<= 4;
s[num + j] |= m;
}
bs->length = num;
bs->data = s;
- ret = 1;
+ return 1;
+
err:
- if (0) {
- err_sl:
- ASN1err(ASN1_F_A2I_ASN1_ENUMERATED, ASN1_R_SHORT_LINE);
- }
- return (ret);
+ ASN1err(ASN1_F_A2I_ASN1_ENUMERATED, ASN1_R_SHORT_LINE);
+ return 0;
}
int a2i_ASN1_INTEGER(BIO *bp, ASN1_INTEGER *bs, char *buf, int size)
{
- int ret = 0;
int i, j, k, m, n, again, bufsize;
unsigned char *s = NULL, *sp;
unsigned char *bufp;
bufsize = BIO_gets(bp, buf, size);
for (;;) {
if (bufsize < 1)
- goto err_sl;
+ goto err;
i = bufsize;
if (buf[i - 1] == '\n')
buf[--i] = '\0';
if (i == 0)
- goto err_sl;
+ goto err;
if (buf[i - 1] == '\r')
buf[--i] = '\0';
if (i == 0)
- goto err_sl;
+ goto err;
again = (buf[i - 1] == '\\');
for (j = 0; j < i; j++) {
* We have now cleared all the crap off the end of the line
*/
if (i < 2)
- goto err_sl;
+ goto err;
bufp = (unsigned char *)buf;
if (first) {
i -= again;
if (i % 2 != 0) {
ASN1err(ASN1_F_A2I_ASN1_INTEGER, ASN1_R_ODD_NUMBER_OF_CHARS);
- goto err;
+ return 0;
}
i /= 2;
if (num + i > slen) {
if (sp == NULL) {
ASN1err(ASN1_F_A2I_ASN1_INTEGER, ERR_R_MALLOC_FAILURE);
OPENSSL_free(s);
- goto err;
+ return 0;
}
s = sp;
slen = num + i * 2;
}
bs->length = num;
bs->data = s;
- ret = 1;
+ return 1;
err:
- if (0) {
- err_sl:
- ASN1err(ASN1_F_A2I_ASN1_INTEGER, ASN1_R_SHORT_LINE);
- }
- return (ret);
+ ASN1err(ASN1_F_A2I_ASN1_INTEGER, ASN1_R_SHORT_LINE);
+ return 0;
}
int a2i_ASN1_STRING(BIO *bp, ASN1_STRING *bs, char *buf, int size)
{
- int ret = 0;
int i, j, k, m, n, again, bufsize;
unsigned char *s = NULL, *sp;
unsigned char *bufp;
if (first)
break;
else
- goto err_sl;
+ goto err;
}
first = 0;
if (buf[i - 1] == '\n')
buf[--i] = '\0';
if (i == 0)
- goto err_sl;
+ goto err;
if (buf[i - 1] == '\r')
buf[--i] = '\0';
if (i == 0)
- goto err_sl;
+ goto err;
again = (buf[i - 1] == '\\');
for (j = i - 1; j > 0; j--) {
* We have now cleared all the crap off the end of the line
*/
if (i < 2)
- goto err_sl;
+ goto err;
bufp = (unsigned char *)buf;
i -= again;
if (i % 2 != 0) {
ASN1err(ASN1_F_A2I_ASN1_STRING, ASN1_R_ODD_NUMBER_OF_CHARS);
- goto err;
+ return 0;
}
i /= 2;
if (num + i > slen) {
if (sp == NULL) {
ASN1err(ASN1_F_A2I_ASN1_STRING, ERR_R_MALLOC_FAILURE);
OPENSSL_free(s);
- goto err;
+ return 0;
}
s = sp;
slen = num + i * 2;
else {
ASN1err(ASN1_F_A2I_ASN1_STRING,
ASN1_R_NON_HEX_CHARACTERS);
- goto err;
+ return 0;
}
s[num + j] <<= 4;
s[num + j] |= m;
}
bs->length = num;
bs->data = s;
- ret = 1;
+ return 1;
+
err:
- if (0) {
- err_sl:
- ASN1err(ASN1_F_A2I_ASN1_STRING, ASN1_R_SHORT_LINE);
- }
- return (ret);
+ ASN1err(ASN1_F_A2I_ASN1_STRING, ASN1_R_SHORT_LINE);
+ return 0;
}
int X509_NAME_print(BIO *bp, X509_NAME *name, int obase)
{
char *s, *c, *b;
- int ret = 0, l, i;
+ int l, i;
l = 80 - 2 - obase;
l--;
}
- ret = 1;
- if (0) {
+ OPENSSL_free(b);
+ return 1;
err:
- X509err(X509_F_X509_NAME_PRINT, ERR_R_BUF_LIB);
- }
+ X509err(X509_F_X509_NAME_PRINT, ERR_R_BUF_LIB);
OPENSSL_free(b);
- return (ret);
+ return 0;
}
ASN1_PCTX *ctx, int ptype)
{
unsigned char *m = NULL;
- int reason = ERR_R_BUF_LIB, ret = 0;
+ int reason = ERR_R_BUF_LIB;
size_t buf_len = 0;
const char *ktype = NULL;
goto err;
}
- ret = 1;
- if (0) {
+ OPENSSL_free(m);
+ return 1;
+
err:
- DHerr(DH_F_DO_DH_PRINT, reason);
- }
+ DHerr(DH_F_DO_DH_PRINT, reason);
OPENSSL_free(m);
- return (ret);
+ return 0;
}
static int int_dh_size(const EVP_PKEY *pkey)
/* If we get this far evaluate policies */
if (!bad_chain && (ctx->param->flags & X509_V_FLAG_POLICY_CHECK))
ok = ctx->check_policy(ctx);
- if (!ok)
- goto end;
- if (0) {
+ if (ok)
+ goto done;
+
end:
- X509_get_pubkey_parameters(NULL, ctx->chain);
- }
+ X509_get_pubkey_parameters(NULL, ctx->chain);
+ done:
sk_X509_free(sktmp);
X509_free(chain_ss);
return ok;
goto bad_cache;
} else if (!policy_cache_set_int(&cache->any_skip, ext_any))
goto bad_cache;
+ goto just_cleanup;
- if (0) {
bad_cache:
- x->ex_flags |= EXFLAG_INVALID_POLICY;
- }
+ x->ex_flags |= EXFLAG_INVALID_POLICY;
+ just_cleanup:
if (ext_pcons)
POLICY_CONSTRAINTS_free(ext_pcons);
}
ret = 1;
+ goto done;
- if (0) {
err:
- if (ERR_peek_error() == 0) { /* system call error */
- fprintf(stderr, "errno=%d ", errno);
- perror("error");
- } else
- ERR_print_errors_fp(stderr);
- }
+ if (ERR_peek_error() == 0) { /* system call error */
+ fprintf(stderr, "errno=%d ", errno);
+ perror("error");
+ } else
+ ERR_print_errors_fp(stderr);
+ done:
BIO_free_all(out);
SSL_CTX_free(ssl_ctx);
- exit(!ret);
- return (ret);
+ return (ret == 1);
}
if ((sk = sk_X509_new_null()) == NULL) {
SSLerr(SSL_F_SSL3_GET_SERVER_CERTIFICATE, ERR_R_MALLOC_FAILURE);
- goto err;
+ goto done;
}
n2l3(p, llen);
}
if (!sk_X509_push(sk, x)) {
SSLerr(SSL_F_SSL3_GET_SERVER_CERTIFICATE, ERR_R_MALLOC_FAILURE);
- goto err;
+ goto done;
}
x = NULL;
nc += l + 3;
sc = ssl_sess_cert_new();
if (sc == NULL)
- goto err;
+ goto done;
ssl_sess_cert_free(s->session->sess_cert);
s->session->sess_cert = sc;
x = NULL;
ret = 1;
- if (0) {
+ goto done;
+
f_err:
- ssl3_send_alert(s, SSL3_AL_FATAL, al);
- }
- err:
+ ssl3_send_alert(s, SSL3_AL_FATAL, al);
+ done:
EVP_PKEY_free(pkey);
X509_free(x);
sk_X509_pop_free(sk, X509_free);
ptmp = EVP_PKEY_new();
if (!ptmp)
return 0;
- if (0) ;
#ifndef OPENSSL_NO_RSA
else if (sc->peer_rsa_tmp)
rv = EVP_PKEY_set1_RSA(ptmp, sc->peer_rsa_tmp);
if ((sk = sk_X509_new_null()) == NULL) {
SSLerr(SSL_F_SSL3_GET_CLIENT_CERTIFICATE, ERR_R_MALLOC_FAILURE);
- goto err;
+ goto done;
}
n2l3(p, llen);
x = d2i_X509(NULL, &p, l);
if (x == NULL) {
SSLerr(SSL_F_SSL3_GET_CLIENT_CERTIFICATE, ERR_R_ASN1_LIB);
- goto err;
+ goto done;
}
if (p != (q + l)) {
al = SSL_AD_DECODE_ERROR;
}
if (!sk_X509_push(sk, x)) {
SSLerr(SSL_F_SSL3_GET_CLIENT_CERTIFICATE, ERR_R_MALLOC_FAILURE);
- goto err;
+ goto done;
}
x = NULL;
nc += l + 3;
s->session->sess_cert = ssl_sess_cert_new();
if (s->session->sess_cert == NULL) {
SSLerr(SSL_F_SSL3_GET_CLIENT_CERTIFICATE, ERR_R_MALLOC_FAILURE);
- goto err;
+ goto done;
}
}
sk_X509_pop_free(s->session->sess_cert->cert_chain, X509_free);
* Inconsistency alert: cert_chain does *not* include the peer's own
* certificate, while we do include it in s3_clnt.c
*/
-
sk = NULL;
-
ret = 1;
- if (0) {
+ goto done;
+
f_err:
- ssl3_send_alert(s, SSL3_AL_FATAL, al);
- }
- err:
+ ssl3_send_alert(s, SSL3_AL_FATAL, al);
+ done:
X509_free(x);
sk_X509_pop_free(sk, X509_free);
return (ret);
if (as == NULL)
goto err;
- if (0) {
- i2d_SSL_SESSION_ASN1(NULL, NULL);
- }
-
if (!a || !*a) {
ret = SSL_SESSION_new();
if (ret == NULL)
sk_X509_NAME_push(ret, xn);
}
}
+ goto done;
- if (0) {
err:
- sk_X509_NAME_pop_free(ret, X509_NAME_free);
- ret = NULL;
- }
+ sk_X509_NAME_pop_free(ret, X509_NAME_free);
+ ret = NULL;
+ done:
sk_X509_NAME_free(sk);
BIO_free(in);
X509_free(x);
}
ERR_clear_error();
+ goto done;
- if (0) {
err:
ret = 0;
- }
+ done:
BIO_free(in);
if (x != NULL)
X509_free(x);
-
(void)sk_X509_NAME_set_cmp_func(stack, oldcmp);
-
return ret;
}
}
}
}
+ return ret;
- if (0) {
err:
- SSL_free(ret);
- ret = NULL;
- }
- return (ret);
+ SSL_free(ret);
+ return NULL;
}
void ssl_clear_cipher_ctx(SSL *s)