From f50c8e40b57d87fef207e1a80efaa3e6c6ff6a36 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sat, 20 Feb 2010 09:00:45 +0000 Subject: [PATCH] Fixing issue mentioned below. From: Jesse Anderton To: Christian Grothoff Date: Yesterday 11:50:56 pm Christian, I'm not sure whether this counts as a bug or not, but I found that if you use MHD_OPTION_CIPHER_ALGORITHM or MHD_OPTION_PROTOCOL_VERSION in MHD_start_daemon() without using MHD_USE_SSL a SIGSEGV will result. This signal is sent because the daemon's priority_cache member is dereferenced in MHD_start_daemon_va(), but this member is only initialized if MHD_USE_SSL is used. This doesn't affect me: a workaround is easy. I just wanted to make sure you were aware of it. Regards, Jesse --- src/daemon/daemon.c | 40 ++++++++++++++++++++++++++++++++++------ 1 file changed, 34 insertions(+), 6 deletions(-) diff --git a/src/daemon/daemon.c b/src/daemon/daemon.c index 5c422061..d895bedb 100644 --- a/src/daemon/daemon.c +++ b/src/daemon/daemon.c @@ -1248,18 +1248,46 @@ parse_options_va (struct MHD_Daemon *daemon, break; #if HTTPS_SUPPORT case MHD_OPTION_PROTOCOL_VERSION: - _set_priority (&daemon->priority_cache->protocol, - va_arg (ap, const int *)); + if (daemon->options & MHD_USE_SSL) + _set_priority (&daemon->priority_cache->protocol, + va_arg (ap, const int *)); +#if HAVE_MESSAGES + else + FPRINTF (stderr, + "MHD HTTPS option %d passed to MHD but MHD_USE_SSL not set\n", + opt); +#endif break; case MHD_OPTION_HTTPS_MEM_KEY: - daemon->https_mem_key = va_arg (ap, const char *); + if (daemon->options & MHD_USE_SSL) + daemon->https_mem_key = va_arg (ap, const char *); +#if HAVE_MESSAGES + else + FPRINTF (stderr, + "MHD HTTPS option %d passed to MHD but MHD_USE_SSL not set\n", + opt); +#endif break; case MHD_OPTION_HTTPS_MEM_CERT: - daemon->https_mem_cert = va_arg (ap, const char *); + if (daemon->options & MHD_USE_SSL) + daemon->https_mem_cert = va_arg (ap, const char *); +#if HAVE_MESSAGES + else + FPRINTF (stderr, + "MHD HTTPS option %d passed to MHD but MHD_USE_SSL not set\n", + opt); +#endif break; case MHD_OPTION_CIPHER_ALGORITHM: - _set_priority (&daemon->priority_cache->cipher, - va_arg (ap, const int *)); + if (daemon->options & MHD_USE_SSL) + _set_priority (&daemon->priority_cache->cipher, + va_arg (ap, const int *)); +#if HAVE_MESSAGES + else + FPRINTF (stderr, + "MHD HTTPS option %d passed to MHD but MHD_USE_SSL not set\n", + opt); +#endif break; #endif case MHD_OPTION_EXTERNAL_LOGGER: