[dovecot-cvs] dovecot/src/master ssl-init-openssl.c, 1.6.2.1,
1.6.2.2
cras at dovecot.org
cras at dovecot.org
Wed May 31 16:59:15 EEST 2006
Update of /var/lib/cvs/dovecot/src/master
In directory talvi:/tmp/cvs-serv9004
Modified Files:
Tag: branch_1_0
ssl-init-openssl.c
Log Message:
Reversed last change. Instead handle DH_generate_parameters() call's
failure.
Index: ssl-init-openssl.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/master/ssl-init-openssl.c,v
retrieving revision 1.6.2.1
retrieving revision 1.6.2.2
diff -u -d -r1.6.2.1 -r1.6.2.2
--- ssl-init-openssl.c 31 May 2006 13:54:08 -0000 1.6.2.1
+++ ssl-init-openssl.c 31 May 2006 13:59:13 -0000 1.6.2.2
@@ -17,21 +17,36 @@
#define DH_PARAM_BITSIZE_COUNT \
(sizeof(dh_param_bitsizes)/sizeof(dh_param_bitsizes[0]))
+static const char *ssl_last_error(void)
+{
+ unsigned long err;
+ char *buf;
+ size_t err_size = 256;
+
+ err = ERR_get_error();
+ if (err == 0)
+ return strerror(errno);
+
+ buf = t_malloc(err_size);
+ buf[err_size-1] = '\0';
+ ERR_error_string_n(err, buf, err_size-1);
+ return buf;
+}
+
static void generate_dh_parameters(int bitsize, int fd, const char *fname)
{
DH *dh = DH_generate_parameters(bitsize, DH_GENERATOR, NULL, NULL);
unsigned char *buf, *p;
int len;
+ if (dh == NULL) {
+ i_fatal("DH_generate_parameters(bits=%d, gen=%d) failed: %s",
+ bitsize, DH_GENERATOR, ssl_last_error());
+ }
+
len = i2d_DHparams(dh, NULL);
if (len < 0)
- i_fatal("i2d_DHparams() failed: %lu", ERR_get_error());
-
- if (len == 0) {
- i_fatal("i2d_DHparams() returned 0 for data from "
- "DH_generate_parameters(bits=%d, generator=%d)",
- bitsize, DH_GENERATOR);
- }
+ i_fatal("i2d_DHparams() failed: %s", ssl_last_error());
buf = p = i_malloc(len);
len = i2d_DHparams(dh, &p);
More information about the dovecot-cvs
mailing list