gnutls_pk_algorithm_t requested_algo)
{
unsigned i;
- int idx, ret;
+ int idx;
gnutls_certificate_credentials_t cred;
cred = (gnutls_certificate_credentials_t)
/* Otherwise... */
- ret = 0;
idx = -1; /* default is use no certificate */
/* store the certificate pointer for future use, in the handshake.
* (This will allow not calling this callback again.)
*/
- if (idx >= 0 && ret == 0)
+ if (idx >= 0)
{
_gnutls_selected_certs_set (session,
&cred->cert_list[idx][0],
}
else
/* Certificate does not support REQUESTED_ALGO. */
- ret = GNUTLS_E_INSUFFICIENT_CREDENTIALS;
+ return GNUTLS_E_INSUFFICIENT_CREDENTIALS;
- return ret;
+ return 0;
}
/* Frees the rsa_info_st structure.
/* Setup the master secret
*/
- if ((ret = _gnutls_generate_master (session, 0), 0) < 0)
+ if ((ret = _gnutls_generate_master (session, 0)) < 0)
{
gnutls_assert ();
return ret;
int ret;
gnutls_datum_t vdata;
- if (cert->version == 0 || cert == NULL)
+ if (cert == NULL || cert->version == 0)
{ /* this is the only way to check
* if it is initialized
*/
/* If the certificate supports signing continue.
*/
- if (cert != NULL)
- if (cert->key_usage != 0)
+ if (cert->key_usage != 0)
if (!(cert->key_usage & KEY_DIGITAL_SIGNATURE))
{
gnutls_assert ();
char *
X509_NAME_oneline (gnutls_x509_dn * name, char *buf, int len)
{
- memset (buf, 0, len);
+ /* XXX openssl allocates buffer if buf == NULL */
if (!buf)
return NULL;
+ memset (buf, 0, len);
snprintf (buf, len - 1,
"C=%s, ST=%s, L=%s, O=%s, OU=%s, CN=%s/Email=%s",
/* Verify using internal algorithm too. */
{
int verify_status;
- int comma;
ret = gnutls_x509_crt_list_verify (x509_cert_list, x509_ncerts,
&x509_cert_list[x509_ncerts - 1], 1,
if (verify_status & GNUTLS_CERT_INVALID)
{
fprintf (outfile, "Not verified");
- comma = 1;
}
else
{
fprintf (outfile, "Verified");
- comma = 1;
}
if (verify_status & GNUTLS_CERT_SIGNER_NOT_CA)
{
- if (comma)
- fprintf (outfile, ", ");
+ fprintf (outfile, ", ");
fprintf (outfile, "Issuer is not a CA");
- comma = 1;
}
if (verify_status & GNUTLS_CERT_INSECURE_ALGORITHM)
{
- if (comma)
- fprintf (outfile, ", ");
+ fprintf (outfile, ", ");
fprintf (outfile, "Insecure algorithm");
- comma = 1;
}
fprintf (outfile, ".\n");
for (i = 0; i < CFG_N_PROPS; i++) {
con->prop[i] = PLATON_FUNC(strdyn_create_ar)(cfg_default_properties[i]);
if (con->prop[i] == NULL) {
- /* TODO: possible freeing on failure */
+ cfg_free_context(con);
return NULL;
}
}
s_size = strstr(s, sep) - s;
- if ((ar[i] = (char*) malloc((s_size + 1) * sizeof(char))) == NULL)
+ if ((ar[i] = (char*) malloc((s_size + 1) * sizeof(char))) == NULL) {
+ PLATON_FUNC(strdyn_free)(ar);
return NULL;
+ }
strncpy(ar[i], s, s_size);
ar[i][s_size] = '\0';
}
- if ((ar[ar_size] = strdup(s)) == NULL)
+ if ((ar[ar_size] = strdup(s)) == NULL) {
+ PLATON_FUNC(strdyn_free)(ar);
return NULL;
+ }
ar[ar_size + 1] = NULL;
http_buffer = malloc (len);
if (http_buffer == NULL)
- return NULL;
+ {
+ free(crtinfo);
+ return NULL;
+ }
strcpy (http_buffer, HTTP_BEGIN);
strcat (http_buffer, "<hr><PRE>");
strcat (http_buffer, crtinfo);
strcat (http_buffer, "\n</PRE>\n");
+ free(crtinfo);
}
strcat (http_buffer, "<hr><P>Your HTTP header was:<PRE>");