From 03573e80f7f70b8f37af1adc7fdfa0ac2bf1b5af Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sat, 27 Dec 2008 07:49:35 +0000 Subject: indent --- src/daemon/connection.c | 82 +++--- src/daemon/connection_https.c | 13 +- src/daemon/daemon.c | 14 +- src/daemon/https/tls/auth_rsa.c | 4 +- src/daemon/https/tls/ext_cert_type.c | 8 +- src/daemon/https/tls/ext_max_record.c | 4 +- src/daemon/https/tls/ext_server_name.c | 24 +- src/daemon/https/tls/gnutls_algorithms.c | 4 +- src/daemon/https/tls/gnutls_auth.c | 5 +- src/daemon/https/tls/gnutls_buffers.c | 25 +- src/daemon/https/tls/gnutls_cipher.c | 41 ++- src/daemon/https/tls/gnutls_constate.c | 75 +++--- src/daemon/https/tls/gnutls_extensions.c | 5 +- src/daemon/https/tls/gnutls_handshake.c | 63 +++-- src/daemon/https/tls/gnutls_kx.c | 66 +++-- src/daemon/https/tls/gnutls_pk.c | 2 - src/daemon/https/tls/gnutls_record.c | 16 +- src/daemon/https/tls/gnutls_sig.c | 24 +- src/daemon/https/tls/gnutls_state.c | 4 +- src/daemon/https/tls/gnutls_x509.c | 4 +- src/daemon/https/tls/memmem.c | 9 +- src/daemon/https/tls/str-two-way.h | 370 +++++++++++++-------------- src/daemon/internal.c | 4 +- src/daemon/internal.h | 28 +- src/include/microhttpd.h | 7 +- src/testcurl/daemontest_parse_cookies.c | 44 ++-- src/testcurl/daemontest_process_headers.c | 88 +++---- src/testcurl/https/bug-test.c | 2 +- src/testcurl/https/mhds_multi_daemon_test.c | 2 +- src/testcurl/https/tls_authentication_test.c | 2 +- src/testcurl/https/tls_daemon_options_test.c | 6 +- src/testcurl/https/tls_thread_mode_test.c | 77 +++--- 32 files changed, 531 insertions(+), 591 deletions(-) diff --git a/src/daemon/connection.c b/src/daemon/connection.c index e3818097..b049d1a5 100644 --- a/src/daemon/connection.c +++ b/src/daemon/connection.c @@ -288,9 +288,8 @@ MHD_connection_close (struct MHD_Connection *connection, connection->socket_fd = -1; connection->state = MHD_CONNECTION_CLOSED; if (connection->daemon->notify_completed != NULL) - connection->daemon->notify_completed (connection-> - daemon->notify_completed_cls, - connection, + connection->daemon->notify_completed (connection->daemon-> + notify_completed_cls, connection, &connection->client_context, termination_code); } @@ -976,35 +975,29 @@ parse_cookie_header (struct MHD_Connection *connection) while (pos != NULL) { while (*pos == ' ') - pos++; /* skip spaces */ - + pos++; /* skip spaces */ + sce = pos; - while ( ( (*sce) != '\0') && - ( (*sce) != ',') && - ( (*sce) != ';') && - ( (*sce) != '=') ) - sce++; + while (((*sce) != '\0') && + ((*sce) != ',') && ((*sce) != ';') && ((*sce) != '=')) + sce++; /* remove tailing whitespace (if any) from key */ ekill = sce - 1; - while ( (*ekill == ' ') && - (ekill >= pos) ) - *(ekill--) = '\0'; + while ((*ekill == ' ') && (ekill >= pos)) + *(ekill--) = '\0'; old = *sce; *sce = '\0'; if (old != '=') - { - /* value part omitted, use empty string... */ - if (MHD_NO == - connection_add_header (connection, - pos, - "", - MHD_COOKIE_KIND)) - return MHD_NO; - if (old == '\0') - break; - pos = sce + 1; - continue; - } + { + /* value part omitted, use empty string... */ + if (MHD_NO == + connection_add_header (connection, pos, "", MHD_COOKIE_KIND)) + return MHD_NO; + if (old == '\0') + break; + pos = sce + 1; + continue; + } equals = sce + 1; quotes = 0; semicolon = equals; @@ -1068,9 +1061,8 @@ parse_initial_message_line (struct MHD_Connection *connection, char *line) if (connection->daemon->uri_log_callback != NULL) connection->client_context = - connection->daemon->uri_log_callback (connection-> - daemon->uri_log_callback_cls, - uri); + connection->daemon->uri_log_callback (connection->daemon-> + uri_log_callback_cls, uri); args = strstr (uri, "?"); if (args != NULL) { @@ -1218,8 +1210,8 @@ call_connection_handler (struct MHD_Connection *connection) } used = processed; if (MHD_NO == - connection->daemon->default_handler (connection-> - daemon->default_handler_cls, + connection->daemon->default_handler (connection->daemon-> + default_handler_cls, connection, connection->url, connection->method, connection->version, @@ -1620,11 +1612,9 @@ MHD_connection_handle_write (struct MHD_Connection *connection) case MHD_CONNECTION_CONTINUE_SENDING: ret = connection->send_cls (connection, &HTTP_100_CONTINUE - [connection-> - continue_message_write_offset], + [connection->continue_message_write_offset], strlen (HTTP_100_CONTINUE) - - connection-> - continue_message_write_offset); + connection->continue_message_write_offset); if (ret < 0) { if (errno == EINTR) @@ -1674,12 +1664,12 @@ MHD_connection_handle_write (struct MHD_Connection *connection) { ret = MHD__gnutls_record_send (connection->tls_session, &connection->response->data - [connection->response_write_position - - response->data_start], - response->data_size - - (connection-> + [connection-> response_write_position - - response->data_start)); + response->data_start], + response->data_size - + (connection->response_write_position + - response->data_start)); } else #endif @@ -1749,10 +1739,10 @@ MHD_connection_handle_write (struct MHD_Connection *connection) case MHD_TLS_HANDSHAKE_FAILED: EXTRA_CHECK (0); break; - default: - EXTRA_CHECK (0); - connection_close_error (connection); - return MHD_NO; + default: + EXTRA_CHECK (0); + connection_close_error (connection); + return MHD_NO; } break; } @@ -2043,8 +2033,8 @@ MHD_connection_handle_idle (struct MHD_Connection *connection) #endif MHD_destroy_response (connection->response); if (connection->daemon->notify_completed != NULL) - connection->daemon->notify_completed (connection-> - daemon->notify_completed_cls, + connection->daemon->notify_completed (connection->daemon-> + notify_completed_cls, connection, &connection->client_context, MHD_REQUEST_TERMINATED_COMPLETED_OK); diff --git a/src/daemon/connection_https.c b/src/daemon/connection_https.c index 86b5ff16..afe52226 100644 --- a/src/daemon/connection_https.c +++ b/src/daemon/connection_https.c @@ -58,11 +58,11 @@ MHD_get_connection_info (struct MHD_Connection *connection, { #if HTTPS_SUPPORT case MHD_CONNECTION_INFO_CIPHER_ALGO: - return (const union MHD_ConnectionInfo *) &connection->tls_session-> - security_parameters.read_bulk_cipher_algorithm; + return (const union MHD_ConnectionInfo *) &connection-> + tls_session->security_parameters.read_bulk_cipher_algorithm; case MHD_CONNECTION_INFO_PROTOCOL: - return (const union MHD_ConnectionInfo *) &connection->tls_session-> - security_parameters.version; + return (const union MHD_ConnectionInfo *) &connection-> + tls_session->security_parameters.version; #endif default: return NULL; @@ -246,9 +246,8 @@ MHD_tls_connection_handle_read (struct MHD_Connection *connection) MHD_DLOG (connection->daemon, "Received TLS alert: %s\n", MHD__gnutls_alert_get_name ((int) - connection-> - tls_session->internals. - last_alert)); + connection->tls_session-> + internals.last_alert)); #endif return MHD_YES; } diff --git a/src/daemon/daemon.c b/src/daemon/daemon.c index 54f7e4c1..9d6943ca 100644 --- a/src/daemon/daemon.c +++ b/src/daemon/daemon.c @@ -835,7 +835,8 @@ MHD_start_daemon_va (unsigned int options, retVal->pool_size = MHD_POOL_SIZE_DEFAULT; retVal->connection_timeout = 0; /* no timeout */ #if HAVE_MESSAGES - retVal->custom_error_log = (void(*)(void*,const char *,va_list)) &vfprintf; + retVal->custom_error_log = + (void (*)(void *, const char *, va_list)) &vfprintf; retVal->custom_error_log_cls = stderr; #endif #if HTTPS_SUPPORT @@ -896,13 +897,14 @@ MHD_start_daemon_va (unsigned int options, va_arg (ap, const int *)); break; #endif - case MHD_OPTION_EXTERNAL_LOGGER: + case MHD_OPTION_EXTERNAL_LOGGER: #if HAVE_MESSAGES - retVal->custom_error_log = va_arg(ap, void (*)(void*cls, const char *, va_list)); - retVal->custom_error_log_cls = va_arg(ap, void *); + retVal->custom_error_log = + va_arg (ap, void (*)(void *cls, const char *, va_list)); + retVal->custom_error_log_cls = va_arg (ap, void *); #else - va_arg(ap, void (*)(void*cls, const char *,...)); - va_arg(ap, void *); + va_arg (ap, void (*)(void *cls, const char *, ...)); + va_arg (ap, void *); #endif default: #if HAVE_MESSAGES diff --git a/src/daemon/https/tls/auth_rsa.c b/src/daemon/https/tls/auth_rsa.c index 1b461951..9548a8f1 100644 --- a/src/daemon/https/tls/auth_rsa.c +++ b/src/daemon/https/tls/auth_rsa.c @@ -168,8 +168,8 @@ MHD__gnutls_get_private_rsa_params (MHD_gtls_session_t session, } bits = - MHD__gnutls_mpi_get_nbits (session->internals. - selected_cert_list[0].params[0]); + MHD__gnutls_mpi_get_nbits (session->internals.selected_cert_list[0]. + params[0]); if (MHD_gtls_cipher_suite_get_kx_algo (&session->security_parameters.current_cipher_suite) diff --git a/src/daemon/https/tls/ext_cert_type.c b/src/daemon/https/tls/ext_cert_type.c index 5fc53167..1e7966f4 100644 --- a/src/daemon/https/tls/ext_cert_type.c +++ b/src/daemon/https/tls/ext_cert_type.c @@ -183,8 +183,8 @@ MHD_gtls_cert_type_send_params (MHD_gtls_session_t session, opaque * data, for (i = 0; i < len; i++) { data[i + 1] = - MHD__gnutls_cert_type2num (session->internals.priorities. - cert_type.priority[i]); + MHD__gnutls_cert_type2num (session->internals. + priorities.cert_type.priority[i]); } return len + 1; } @@ -203,8 +203,8 @@ MHD_gtls_cert_type_send_params (MHD_gtls_session_t session, opaque * data, } data[0] = - MHD__gnutls_cert_type2num (session->security_parameters. - cert_type); + MHD__gnutls_cert_type2num (session-> + security_parameters.cert_type); return len; } diff --git a/src/daemon/https/tls/ext_max_record.c b/src/daemon/https/tls/ext_max_record.c index 5dcf2225..421a1739 100644 --- a/src/daemon/https/tls/ext_max_record.c +++ b/src/daemon/https/tls/ext_max_record.c @@ -121,8 +121,8 @@ MHD_gtls_max_record_send_params (MHD_gtls_session_t session, opaque * data, } data[0] = - (uint8_t) MHD_gtls_mre_record2num (session-> - internals.proposed_record_size); + (uint8_t) MHD_gtls_mre_record2num (session->internals. + proposed_record_size); return len; } diff --git a/src/daemon/https/tls/ext_server_name.c b/src/daemon/https/tls/ext_server_name.c index 1441f692..911bd530 100644 --- a/src/daemon/https/tls/ext_server_name.c +++ b/src/daemon/https/tls/ext_server_name.c @@ -118,10 +118,10 @@ MHD_gtls_server_name_recv_params (MHD_gtls_session_t session, case 0: /* NAME_DNS */ if (len <= MAX_SERVER_NAME_SIZE) { - memcpy (session->security_parameters.extensions.server_names[i]. - name, p, len); - session->security_parameters.extensions. - server_names[i].name_length = len; + memcpy (session->security_parameters.extensions. + server_names[i].name, p, len); + session->security_parameters.extensions.server_names[i]. + name_length = len; session->security_parameters.extensions.server_names[i].type = GNUTLS_NAME_DNS; break; @@ -163,8 +163,8 @@ MHD_gtls_server_name_send_params (MHD_gtls_session_t session, /* count the total size */ len = - session->security_parameters.extensions. - server_names[i].name_length; + session->security_parameters.extensions.server_names[i]. + name_length; /* uint8_t + uint16_t + size */ @@ -183,14 +183,14 @@ MHD_gtls_server_name_send_params (MHD_gtls_session_t session, i < session->security_parameters.extensions.server_names_size; i++) { - switch (session->security_parameters.extensions.server_names[i]. - type) + switch (session->security_parameters.extensions. + server_names[i].type) { case GNUTLS_NAME_DNS: len = - session->security_parameters.extensions.server_names[i]. - name_length; + session->security_parameters.extensions. + server_names[i].name_length; if (len == 0) break; @@ -208,8 +208,8 @@ MHD_gtls_server_name_send_params (MHD_gtls_session_t session, p += 2; memcpy (p, - session->security_parameters.extensions.server_names[0]. - name, len); + session->security_parameters.extensions. + server_names[0].name, len); p += len; break; default: diff --git a/src/daemon/https/tls/gnutls_algorithms.c b/src/daemon/https/tls/gnutls_algorithms.c index 55b4ecbf..f65ccbac 100644 --- a/src/daemon/https/tls/gnutls_algorithms.c +++ b/src/daemon/https/tls/gnutls_algorithms.c @@ -1188,8 +1188,8 @@ MHD_gtls_supported_compression_methods (MHD_gtls_session_t session, for (i = j = 0; i < SUPPORTED_COMPRESSION_METHODS; i++) { int tmp = - MHD_gtls_compression_get_num (session->internals. - priorities.compression.priority[i]); + MHD_gtls_compression_get_num (session->internals.priorities. + compression.priority[i]); /* remove private compression algorithms, if requested. */ diff --git a/src/daemon/https/tls/gnutls_auth.c b/src/daemon/https/tls/gnutls_auth.c index df978ef9..7c820c4e 100644 --- a/src/daemon/https/tls/gnutls_auth.c +++ b/src/daemon/https/tls/gnutls_auth.c @@ -166,9 +166,8 @@ MHD_gtls_auth_get_type (MHD_gtls_session_t session) return MHD_gtls_map_kx_get_cred (MHD_gtls_cipher_suite_get_kx_algo - (&session-> - security_parameters.current_cipher_suite), - server); + (&session->security_parameters. + current_cipher_suite), server); } /* diff --git a/src/daemon/https/tls/gnutls_buffers.c b/src/daemon/https/tls/gnutls_buffers.c index 167fd760..fa41f28e 100644 --- a/src/daemon/https/tls/gnutls_buffers.c +++ b/src/daemon/https/tls/gnutls_buffers.c @@ -734,9 +734,9 @@ MHD_gtls_io_write_buffered (MHD_gtls_session_t session, session->internals.record_send_buffer_prev_size += n - left; retval = - MHD__gnutls_buffer_insert (&session->internals. - record_send_buffer, &ptr[n - left], - left); + MHD__gnutls_buffer_insert (&session-> + internals.record_send_buffer, + &ptr[n - left], left); if (retval < 0) { MHD_gnutls_assert (); @@ -944,8 +944,8 @@ MHD_gtls_handshake_io_send_int (MHD_gtls_session_t session, MHD_gnutls_assert (); retval = - MHD__gnutls_buffer_insert (&session-> - internals.handshake_send_buffer, + MHD__gnutls_buffer_insert (&session->internals. + handshake_send_buffer, &ptr[n - left], left); if (retval < 0) { @@ -1047,9 +1047,8 @@ MHD_gtls_handshake_io_recv_int (MHD_gtls_session_t session, session->internals.handshake_recv_buffer.data = - MHD_gtls_realloc_fast (session-> - internals.handshake_recv_buffer.data, - dsize); + MHD_gtls_realloc_fast (session->internals. + handshake_recv_buffer.data, dsize); if (session->internals.handshake_recv_buffer.data == NULL) { MHD_gnutls_assert (); @@ -1100,9 +1099,13 @@ MHD_gtls_handshake_buffer_put (MHD_gtls_session_t session, opaque * data, if ((session->internals.max_handshake_data_buffer_size > 0) && ((length + - session->internals.handshake_hash_buffer.length) - > - session->internals.max_handshake_data_buffer_size)) + session-> + internals. + handshake_hash_buffer. + length) > + session-> + internals. + max_handshake_data_buffer_size)) { MHD_gnutls_assert (); return GNUTLS_E_MEMORY_ERROR; diff --git a/src/daemon/https/tls/gnutls_cipher.c b/src/daemon/https/tls/gnutls_cipher.c index b919aea0..6edc0efe 100644 --- a/src/daemon/https/tls/gnutls_cipher.c +++ b/src/daemon/https/tls/gnutls_cipher.c @@ -212,15 +212,15 @@ MHD_gtls_compressed2ciphertext (MHD_gtls_session_t session, uint8_t type = _type; uint8_t major, minor; int hash_size = - MHD_gnutls_hash_get_algo_len (session-> - security_parameters.write_mac_algorithm); + MHD_gnutls_hash_get_algo_len (session->security_parameters. + write_mac_algorithm); enum MHD_GNUTLS_Protocol ver; int blocksize = - MHD_gtls_cipher_get_block_size (session-> - security_parameters.write_bulk_cipher_algorithm); + MHD_gtls_cipher_get_block_size (session->security_parameters. + write_bulk_cipher_algorithm); cipher_type_t block_algo = - MHD_gtls_cipher_is_block (session-> - security_parameters.write_bulk_cipher_algorithm); + MHD_gtls_cipher_is_block (session->security_parameters. + write_bulk_cipher_algorithm); opaque *data_ptr; @@ -247,9 +247,8 @@ MHD_gtls_compressed2ciphertext (MHD_gtls_session_t session, if (td != GNUTLS_MAC_FAILED) { /* actually when the algorithm in not the NULL one */ MHD_gnutls_hash (td, - UINT64DATA (session-> - connection_state.write_sequence_number), - 8); + UINT64DATA (session->connection_state. + write_sequence_number), 8); MHD_gnutls_hash (td, &type, 1); if (ver >= MHD_GNUTLS_PROTOCOL_TLS1_0) @@ -343,16 +342,16 @@ MHD_gtls_ciphertext2compressed (MHD_gtls_session_t session, uint8_t major, minor; enum MHD_GNUTLS_Protocol ver; int hash_size = - MHD_gnutls_hash_get_algo_len (session-> - security_parameters.read_mac_algorithm); + MHD_gnutls_hash_get_algo_len (session->security_parameters. + read_mac_algorithm); ver = MHD__gnutls_protocol_get_version (session); minor = MHD_gtls_version_get_minor (ver); major = MHD_gtls_version_get_major (ver); blocksize = - MHD_gtls_cipher_get_block_size (session-> - security_parameters.read_bulk_cipher_algorithm); + MHD_gtls_cipher_get_block_size (session->security_parameters. + read_bulk_cipher_algorithm); /* initialize MAC */ @@ -376,9 +375,9 @@ MHD_gtls_ciphertext2compressed (MHD_gtls_session_t session, { case CIPHER_STREAM: if ((ret = - MHD_gtls_cipher_decrypt (session-> - connection_state.read_cipher_state, - ciphertext.data, ciphertext.size)) < 0) + MHD_gtls_cipher_decrypt (session->connection_state. + read_cipher_state, ciphertext.data, + ciphertext.size)) < 0) { MHD_gnutls_assert (); return ret; @@ -395,9 +394,9 @@ MHD_gtls_ciphertext2compressed (MHD_gtls_session_t session, } if ((ret = - MHD_gtls_cipher_decrypt (session-> - connection_state.read_cipher_state, - ciphertext.data, ciphertext.size)) < 0) + MHD_gtls_cipher_decrypt (session->connection_state. + read_cipher_state, ciphertext.data, + ciphertext.size)) < 0) { MHD_gnutls_assert (); return ret; @@ -455,8 +454,8 @@ MHD_gtls_ciphertext2compressed (MHD_gtls_session_t session, if (td != GNUTLS_MAC_FAILED) { MHD_gnutls_hash (td, - UINT64DATA (session-> - connection_state.read_sequence_number), 8); + UINT64DATA (session->connection_state. + read_sequence_number), 8); MHD_gnutls_hash (td, &type, 1); if (ver >= MHD_GNUTLS_PROTOCOL_TLS1_0) diff --git a/src/daemon/https/tls/gnutls_constate.c b/src/daemon/https/tls/gnutls_constate.c index 41167f79..845abfe9 100644 --- a/src/daemon/https/tls/gnutls_constate.c +++ b/src/daemon/https/tls/gnutls_constate.c @@ -105,9 +105,10 @@ MHD__gnutls_set_keys (MHD_gtls_session_t session, int hash_size, int IV_size, { /* TLS 1.0 */ ret = MHD_gtls_PRF (session, - (const unsigned char *) session->security_parameters. - master_secret, TLS_MASTER_SIZE, keyexp, keyexp_length, - rnd, 2 * TLS_RANDOM_SIZE, block_size, key_block); + (const unsigned char *) session-> + security_parameters.master_secret, TLS_MASTER_SIZE, + keyexp, keyexp_length, rnd, 2 * TLS_RANDOM_SIZE, + block_size, key_block); } if (ret < 0) @@ -506,35 +507,35 @@ MHD_gtls_read_connection_state_init (MHD_gtls_session_t session) { rc = MHD_gtls_set_read_cipher (session, MHD_gtls_cipher_suite_get_cipher_algo - (&session-> - security_parameters.current_cipher_suite)); + (&session->security_parameters. + current_cipher_suite)); if (rc < 0) return rc; rc = MHD_gtls_set_read_mac (session, MHD_gtls_cipher_suite_get_mac_algo - (&session-> - security_parameters.current_cipher_suite)); + (&session->security_parameters. + current_cipher_suite)); if (rc < 0) return rc; rc = MHD_gtls_set_kx (session, MHD_gtls_cipher_suite_get_kx_algo - (&session-> - security_parameters.current_cipher_suite)); + (&session->security_parameters. + current_cipher_suite)); if (rc < 0) return rc; rc = MHD_gtls_set_read_compression (session, - session-> - internals.compression_method); + session->internals. + compression_method); if (rc < 0) return rc; } else { /* RESUME_TRUE */ MHD__gnutls_cpy_read_security_parameters (&session->security_parameters, - &session-> - internals.resumed_security_parameters); + &session->internals. + resumed_security_parameters); } @@ -545,8 +546,8 @@ MHD_gtls_read_connection_state_init (MHD_gtls_session_t session) MHD__gnutls_handshake_log ("HSK[%x]: Cipher Suite: %s\n", session, MHD_gtls_cipher_suite_get_name - (&session-> - security_parameters.current_cipher_suite)); + (&session->security_parameters. + current_cipher_suite)); if (MHD_gtls_compression_is_ok (session->security_parameters.read_compression_algorithm) != 0) @@ -571,8 +572,8 @@ MHD_gtls_read_connection_state_init (MHD_gtls_session_t session) MHD_gnutls_cipher_deinit (session->connection_state.read_cipher_state); mac_size = - MHD_gnutls_hash_get_algo_len (session-> - security_parameters.read_mac_algorithm); + MHD_gnutls_hash_get_algo_len (session->security_parameters. + read_mac_algorithm); MHD__gnutls_handshake_log ("HSK[%x]: Initializing internal [read] cipher sessions\n", session); @@ -583,8 +584,8 @@ MHD_gtls_read_connection_state_init (MHD_gtls_session_t session) /* initialize cipher session */ session->connection_state.read_cipher_state = - MHD_gtls_cipher_init (session-> - security_parameters.read_bulk_cipher_algorithm, + MHD_gtls_cipher_init (session->security_parameters. + read_bulk_cipher_algorithm, &session->cipher_specs.client_write_key, &session->cipher_specs.client_write_IV); if (session->connection_state.read_cipher_state == GNUTLS_CIPHER_FAILED @@ -615,8 +616,8 @@ MHD_gtls_read_connection_state_init (MHD_gtls_session_t session) #if MHD_DEBUG_TLS case GNUTLS_CLIENT: session->connection_state.read_cipher_state = - MHD_gtls_cipher_init (session-> - security_parameters.read_bulk_cipher_algorithm, + MHD_gtls_cipher_init (session->security_parameters. + read_bulk_cipher_algorithm, &session->cipher_specs.server_write_key, &session->cipher_specs.server_write_IV); @@ -674,27 +675,27 @@ MHD_gtls_write_connection_state_init (MHD_gtls_session_t session) { rc = MHD_gtls_set_write_cipher (session, MHD_gtls_cipher_suite_get_cipher_algo - (&session-> - security_parameters.current_cipher_suite)); + (&session->security_parameters. + current_cipher_suite)); if (rc < 0) return rc; rc = MHD_gtls_set_write_mac (session, MHD_gtls_cipher_suite_get_mac_algo - (&session-> - security_parameters.current_cipher_suite)); + (&session->security_parameters. + current_cipher_suite)); if (rc < 0) return rc; rc = MHD_gtls_set_kx (session, MHD_gtls_cipher_suite_get_kx_algo - (&session-> - security_parameters.current_cipher_suite)); + (&session->security_parameters. + current_cipher_suite)); if (rc < 0) return rc; rc = MHD_gtls_set_write_compression (session, - session-> - internals.compression_method); + session->internals. + compression_method); if (rc < 0) return rc; } @@ -711,8 +712,8 @@ MHD_gtls_write_connection_state_init (MHD_gtls_session_t session) MHD__gnutls_handshake_log ("HSK[%x]: Cipher Suite: %s\n", session, MHD_gtls_cipher_suite_get_name - (&session-> - security_parameters.current_cipher_suite)); + (&session->security_parameters. + current_cipher_suite)); if (MHD_gtls_compression_is_ok (session->security_parameters.write_compression_algorithm) != 0) @@ -739,8 +740,8 @@ MHD_gtls_write_connection_state_init (MHD_gtls_session_t session) MHD_gnutls_cipher_deinit (session->connection_state.write_cipher_state); mac_size = - MHD_gnutls_hash_get_algo_len (session-> - security_parameters.write_mac_algorithm); + MHD_gnutls_hash_get_algo_len (session->security_parameters. + write_mac_algorithm); MHD__gnutls_handshake_log ("HSK[%x]: Initializing internal [write] cipher sessions\n", session); @@ -751,8 +752,8 @@ MHD_gtls_write_connection_state_init (MHD_gtls_session_t session) /* initialize cipher session */ session->connection_state.write_cipher_state = - MHD_gtls_cipher_init (session-> - security_parameters.write_bulk_cipher_algorithm, + MHD_gtls_cipher_init (session->security_parameters. + write_bulk_cipher_algorithm, &session->cipher_specs.server_write_key, &session->cipher_specs.server_write_IV); @@ -787,8 +788,8 @@ MHD_gtls_write_connection_state_init (MHD_gtls_session_t session) #if MHD_DEBUG_TLS case GNUTLS_CLIENT: session->connection_state.write_cipher_state = - MHD_gtls_cipher_init (session-> - security_parameters.write_bulk_cipher_algorithm, + MHD_gtls_cipher_init (session->security_parameters. + write_bulk_cipher_algorithm, &session->cipher_specs.client_write_key, &session->cipher_specs.client_write_IV); diff --git a/src/daemon/https/tls/gnutls_extensions.c b/src/daemon/https/tls/gnutls_extensions.c index a46ef838..8ee96c65 100644 --- a/src/daemon/https/tls/gnutls_extensions.c +++ b/src/daemon/https/tls/gnutls_extensions.c @@ -204,9 +204,8 @@ MHD__gnutls_extension_list_add (MHD_gtls_session_t session, uint16_t type) { if (session->internals.extensions_sent_size < MAX_EXT_TYPES) { - session->internals.extensions_sent[session-> - internals.extensions_sent_size] = - type; + session->internals.extensions_sent[session->internals. + extensions_sent_size] = type; session->internals.extensions_sent_size++; } else diff --git a/src/daemon/https/tls/gnutls_handshake.c b/src/daemon/https/tls/gnutls_handshake.c index 980afacd..906350e2 100644 --- a/src/daemon/https/tls/gnutls_handshake.c +++ b/src/daemon/https/tls/gnutls_handshake.c @@ -171,13 +171,11 @@ MHD__gnutls_ssl3_finished (MHD_gtls_session_t session, int type, opaque * ret) MHD_gnutls_hash (td_sha, mesg, siz); MHD_gnutls_mac_deinit_ssl3_handshake (td_md5, ret, - session-> - security_parameters.master_secret, - TLS_MASTER_SIZE); + session->security_parameters. + master_secret, TLS_MASTER_SIZE); MHD_gnutls_mac_deinit_ssl3_handshake (td_sha, &ret[16], - session-> - security_parameters.master_secret, - TLS_MASTER_SIZE); + session->security_parameters. + master_secret, TLS_MASTER_SIZE); return 0; } @@ -359,9 +357,9 @@ MHD__gnutls_read_client_hello (MHD_gtls_session_t session, opaque * data, pos += session_id_len; MHD_gtls_generate_session_id (session->security_parameters.session_id, - &session-> - security_parameters.session_id_size); - + &session->security_parameters. + session_id_size); + session->internals.resumed = RESUME_FALSE; /* Remember ciphersuites for later */ @@ -708,9 +706,9 @@ finish: */ if (MHD_gtls_get_kx_cred (session, - MHD_gtls_cipher_suite_get_kx_algo (&session-> - security_parameters.current_cipher_suite), - &err) == NULL && err != 0) + MHD_gtls_cipher_suite_get_kx_algo (&session->security_parameters. + current_cipher_suite), &err) == NULL + && err != 0) { MHD_gnutls_assert (); return GNUTLS_E_INSUFFICIENT_CREDENTIALS; @@ -723,8 +721,8 @@ finish: */ session->internals.auth_struct = MHD_gtls_kx_auth_struct (MHD_gtls_cipher_suite_get_kx_algo - (&session-> - security_parameters.current_cipher_suite)); + (&session->security_parameters. + current_cipher_suite)); if (session->internals.auth_struct == NULL) { @@ -931,8 +929,8 @@ MHD__gnutls_recv_handshake_header (MHD_gtls_session_t session, if (session->internals.handshake_header_buffer.header_size == handshake_header_size || (session->internals.v2_hello != 0 && type == GNUTLS_HANDSHAKE_CLIENT_HELLO - && session->internals.handshake_header_buffer. - packet_length > 0)) + && session->internals. + handshake_header_buffer.packet_length > 0)) { *recv_type = session->internals.handshake_header_buffer.recv_type; @@ -975,13 +973,11 @@ MHD__gnutls_recv_handshake_header (MHD_gtls_session_t session, MHD_gtls_handshake_io_recv_int (session, GNUTLS_HANDSHAKE, type, &dataptr - [session-> - internals.handshake_header_buffer. - header_size], + [session->internals. + handshake_header_buffer.header_size], HANDSHAKE_HEADER_SIZE - - session-> - internals.handshake_header_buffer. - header_size); + session->internals. + handshake_header_buffer.header_size); if (ret <= 0) { MHD_gnutls_assert (); @@ -1164,12 +1160,11 @@ MHD_gtls_recv_handshake (MHD_gtls_session_t session, uint8_t ** data, ret = MHD__gnutls_handshake_hash_add_recvd (session, recv_type, - session-> - internals.handshake_header_buffer. - header, - session-> - internals.handshake_header_buffer. - header_size, dataptr, length32); + session->internals. + handshake_header_buffer.header, + session->internals. + handshake_header_buffer.header_size, + dataptr, length32); if (ret < 0) { MHD_gnutls_assert (); @@ -1263,8 +1258,8 @@ MHD__gnutls_client_set_ciphersuite (MHD_gtls_session_t session, MHD__gnutls_handshake_log ("HSK[%x]: Selected cipher suite: %s\n", session, MHD_gtls_cipher_suite_get_name - (&session-> - security_parameters.current_cipher_suite)); + (&session->security_parameters. + current_cipher_suite)); /* check if the credentials (username, public key etc.) are ok. @@ -1287,8 +1282,8 @@ MHD__gnutls_client_set_ciphersuite (MHD_gtls_session_t session, */ session->internals.auth_struct = MHD_gtls_kx_auth_struct (MHD_gtls_cipher_suite_get_kx_algo - (&session-> - security_parameters.current_cipher_suite)); + (&session->security_parameters. + current_cipher_suite)); if (session->internals.auth_struct == NULL) { @@ -1862,8 +1857,8 @@ MHD__gnutls_send_server_hello (MHD_gtls_session_t session, int again) pos += 2; comp = - (uint8_t) MHD_gtls_compression_get_num (session->internals. - compression_method); + (uint8_t) MHD_gtls_compression_get_num (session-> + internals.compression_method); data[pos++] = comp; diff --git a/src/daemon/https/tls/gnutls_kx.c b/src/daemon/https/tls/gnutls_kx.c index f1824f03..a4041e39 100644 --- a/src/daemon/https/tls/gnutls_kx.c +++ b/src/daemon/https/tls/gnutls_kx.c @@ -65,13 +65,13 @@ generate_normal_master (MHD_gtls_session_t session, int keep_premaster) MHD_gtls_bin2hex (PREMASTER.data, PREMASTER.size, buf, sizeof (buf))); MHD__gnutls_hard_log ("INT: CLIENT RANDOM[%d]: %s\n", 32, - MHD_gtls_bin2hex (session-> - security_parameters.client_random, - 32, buf, sizeof (buf))); + MHD_gtls_bin2hex (session->security_parameters. + client_random, 32, buf, + sizeof (buf))); MHD__gnutls_hard_log ("INT: SERVER RANDOM[%d]: %s\n", 32, - MHD_gtls_bin2hex (session-> - security_parameters.server_random, - 32, buf, sizeof (buf))); + MHD_gtls_bin2hex (session->security_parameters. + server_random, 32, buf, + sizeof (buf))); if (MHD__gnutls_protocol_get_version (session) == MHD_GNUTLS_PROTOCOL_SSL3) { @@ -86,8 +86,8 @@ generate_normal_master (MHD_gtls_session_t session, int keep_premaster) MHD_gnutls_ssl3_generate_random (PREMASTER.data, PREMASTER.size, rnd, 2 * TLS_RANDOM_SIZE, TLS_MASTER_SIZE, - session-> - security_parameters.master_secret); + session->security_parameters. + master_secret); } else @@ -117,9 +117,8 @@ generate_normal_master (MHD_gtls_session_t session, int keep_premaster) return ret; MHD__gnutls_hard_log ("INT: MASTER SECRET: %s\n", - MHD_gtls_bin2hex (session-> - security_parameters.master_secret, - TLS_MASTER_SIZE, buf, + MHD_gtls_bin2hex (session->security_parameters. + master_secret, TLS_MASTER_SIZE, buf, sizeof (buf))); return ret; @@ -186,8 +185,8 @@ MHD_gtls_send_server_certificate_request (MHD_gtls_session_t session, int data_size = 0; int ret = 0; - if (session->internals. - auth_struct->MHD_gtls_gen_server_certificate_request == NULL) + if (session->internals.auth_struct-> + MHD_gtls_gen_server_certificate_request == NULL) return 0; if (session->internals.send_cert_req <= 0) @@ -199,8 +198,8 @@ MHD_gtls_send_server_certificate_request (MHD_gtls_session_t session, if (again == 0) { data_size = - session->internals. - auth_struct->MHD_gtls_gen_server_certificate_request (session, &data); + session->internals.auth_struct-> + MHD_gtls_gen_server_certificate_request (session, &data); if (data_size < 0) { @@ -299,8 +298,8 @@ MHD_gtls_send_client_certificate_verify (MHD_gtls_session_t session, if (again == 0) { data_size = - session->internals. - auth_struct->MHD_gtls_gen_client_cert_vrfy (session, &data); + session->internals.auth_struct-> + MHD_gtls_gen_client_cert_vrfy (session, &data); if (data_size < 0) { MHD_gnutls_assert (); @@ -372,8 +371,8 @@ MHD_gtls_recv_server_certificate_request (MHD_gtls_session_t session) int datasize; int ret = 0; - if (session->internals. - auth_struct->MHD_gtls_process_server_certificate_request != NULL) + if (session->internals.auth_struct-> + MHD_gtls_process_server_certificate_request != NULL) { ret = @@ -388,10 +387,8 @@ MHD_gtls_recv_server_certificate_request (MHD_gtls_session_t session) return 0; /* ignored */ ret = - session->internals. - auth_struct->MHD_gtls_process_server_certificate_request (session, - data, - datasize); + session->internals.auth_struct-> + MHD_gtls_process_server_certificate_request (session, data, datasize); MHD_gnutls_free (data); if (ret < 0) return ret; @@ -462,8 +459,8 @@ MHD_gtls_send_client_certificate (MHD_gtls_session_t session, int again) /* TLS 1.0 or SSL 3.0 with a valid certificate */ data_size = - session->internals. - auth_struct->MHD_gtls_gen_client_certificate (session, &data); + session->internals.auth_struct-> + MHD_gtls_gen_client_certificate (session, &data); if (data_size < 0) { @@ -523,8 +520,8 @@ MHD_gtls_send_server_certificate (MHD_gtls_session_t session, int again) if (again == 0) { data_size = - session->internals. - auth_struct->MHD_gtls_gen_server_certificate (session, &data); + session->internals.auth_struct-> + MHD_gtls_gen_server_certificate (session, &data); if (data_size < 0) { @@ -620,9 +617,8 @@ MHD_gtls_recv_client_certificate (MHD_gtls_session_t session) return 0; } ret = - session->internals. - auth_struct->MHD_gtls_process_client_certificate (session, data, - datasize); + session->internals.auth_struct-> + MHD_gtls_process_client_certificate (session, data, datasize); MHD_gnutls_free (data); if (ret < 0 && ret != GNUTLS_E_NO_CERTIFICATE_FOUND) @@ -666,9 +662,8 @@ MHD_gtls_recv_server_certificate (MHD_gtls_session_t session) } ret = - session->internals. - auth_struct->MHD_gtls_process_server_certificate (session, data, - datasize); + session->internals.auth_struct-> + MHD_gtls_process_server_certificate (session, data, datasize); MHD_gnutls_free (data); if (ret < 0) { @@ -719,9 +714,8 @@ MHD_gtls_recv_client_certificate_verify_message (MHD_gtls_session_t session) } ret = - session->internals. - auth_struct->MHD_gtls_process_client_cert_vrfy (session, data, - datasize); + session->internals.auth_struct-> + MHD_gtls_process_client_cert_vrfy (session, data, datasize); MHD_gnutls_free (data); if (ret < 0) return ret; diff --git a/src/daemon/https/tls/gnutls_pk.c b/src/daemon/https/tls/gnutls_pk.c index 0d3126a7..f8514cae 100644 --- a/src/daemon/https/tls/gnutls_pk.c +++ b/src/daemon/https/tls/gnutls_pk.c @@ -634,5 +634,3 @@ MHD__gnutls_pk_sign (int algo, mpi_t * data, mpi_t hash, mpi_t * pkey, gcry_sexp_release (s_sig); return 0; } - - diff --git a/src/daemon/https/tls/gnutls_record.c b/src/daemon/https/tls/gnutls_record.c index 075ad97d..07a7b46c 100644 --- a/src/daemon/https/tls/gnutls_record.c +++ b/src/daemon/https/tls/gnutls_record.c @@ -293,8 +293,8 @@ MHD_gtls_send_int (MHD_gtls_session_t session, MHD__gnutls_record_log ("REC[%x]: Sending Packet[%d] %s(%d) with length: %d\n", session, - (int) MHD_gtls_uint64touint32 (&session-> - connection_state.write_sequence_number), + (int) MHD_gtls_uint64touint32 (&session->connection_state. + write_sequence_number), MHD__gnutls_packet2str (type), type, sizeofdata); if (sizeofdata > MAX_RECORD_SEND_SIZE) @@ -856,13 +856,13 @@ begin: MHD__gnutls_record_log ("REC[%x]: Expected Packet[%d] %s(%d) with length: %d\n", session, - (int) MHD_gtls_uint64touint32 (&session-> - connection_state.read_sequence_number), + (int) MHD_gtls_uint64touint32 (&session->connection_state. + read_sequence_number), MHD__gnutls_packet2str (type), type, sizeofdata); MHD__gnutls_record_log ("REC[%x]: Received Packet[%d] %s(%d) with length: %d\n", session, - (int) MHD_gtls_uint64touint32 (&session-> - connection_state.read_sequence_number), + (int) MHD_gtls_uint64touint32 (&session->connection_state. + read_sequence_number), MHD__gnutls_packet2str (recv_type), recv_type, length); if (length > MAX_RECV_SIZE) @@ -938,8 +938,8 @@ begin: MHD__gnutls_record_log ("REC[%x]: Decrypted Packet[%d] %s(%d) with length: %d\n", session, - (int) MHD_gtls_uint64touint32 (&session-> - connection_state.read_sequence_number), + (int) MHD_gtls_uint64touint32 (&session->connection_state. + read_sequence_number), MHD__gnutls_packet2str (recv_type), recv_type, decrypted_length); /* increase sequence number diff --git a/src/daemon/https/tls/gnutls_sig.c b/src/daemon/https/tls/gnutls_sig.c index ec757999..e27c4684 100644 --- a/src/daemon/https/tls/gnutls_sig.c +++ b/src/daemon/https/tls/gnutls_sig.c @@ -75,9 +75,8 @@ MHD_gtls_tls_sign_hdata (MHD_gtls_session_t session, } MHD_gnutls_mac_deinit_ssl3_handshake (td_sha, &concat[16], - session-> - security_parameters.master_secret, - TLS_MASTER_SIZE); + session->security_parameters. + master_secret, TLS_MASTER_SIZE); } else MHD_gnutls_hash_deinit (td_sha, &concat[16]); @@ -95,9 +94,8 @@ MHD_gtls_tls_sign_hdata (MHD_gtls_session_t session, if (ver == MHD_GNUTLS_PROTOCOL_SSL3) MHD_gnutls_mac_deinit_ssl3_handshake (td_md5, concat, - session-> - security_parameters.master_secret, - TLS_MASTER_SIZE); + session->security_parameters. + master_secret, TLS_MASTER_SIZE); else MHD_gnutls_hash_deinit (td_md5, concat); @@ -267,8 +265,8 @@ MHD__gnutls_tls_sign (MHD_gtls_session_t session, return GNUTLS_E_INSUFFICIENT_CREDENTIALS; return (*session->internals.sign_func) (session, - session-> - internals.sign_func_userdata, + session->internals. + sign_func_userdata, cert->cert_type, &cert->raw, hash_concat, signature); } @@ -367,13 +365,11 @@ MHD_gtls_verify_sig_hdata (MHD_gtls_session_t session, } MHD_gnutls_mac_deinit_ssl3_handshake (td_md5, concat, - session-> - security_parameters.master_secret, - TLS_MASTER_SIZE); + session->security_parameters. + master_secret, TLS_MASTER_SIZE); MHD_gnutls_mac_deinit_ssl3_handshake (td_sha, &concat[16], - session-> - security_parameters.master_secret, - TLS_MASTER_SIZE); + session->security_parameters. + master_secret, TLS_MASTER_SIZE); } else { diff --git a/src/daemon/https/tls/gnutls_state.c b/src/daemon/https/tls/gnutls_state.c index f70ec66d..01f51abc 100644 --- a/src/daemon/https/tls/gnutls_state.c +++ b/src/daemon/https/tls/gnutls_state.c @@ -771,8 +771,8 @@ MHD_gtls_session_is_export (MHD_gtls_session_t session) enum MHD_GNUTLS_CipherAlgorithm cipher; cipher = - MHD_gtls_cipher_suite_get_cipher_algo (&session-> - security_parameters.current_cipher_suite); + MHD_gtls_cipher_suite_get_cipher_algo (&session->security_parameters. + current_cipher_suite); if (MHD_gtls_cipher_get_export_flag (cipher) != 0) return 1; diff --git a/src/daemon/https/tls/gnutls_x509.c b/src/daemon/https/tls/gnutls_x509.c index 19475656..685c9642 100644 --- a/src/daemon/https/tls/gnutls_x509.c +++ b/src/daemon/https/tls/gnutls_x509.c @@ -113,8 +113,8 @@ MHD__gnutls_check_key_cert_match (MHD_gtls_cert_credentials_t res) 1].params_size, &kid); - MHD__gnutls_x509_write_rsa_params (res->cert_list[res->ncerts - 1][0]. - params, + MHD__gnutls_x509_write_rsa_params (res-> + cert_list[res->ncerts - 1][0].params, res->cert_list[res->ncerts - 1][0].params_size, &cid); diff --git a/src/daemon/https/tls/memmem.c b/src/daemon/https/tls/memmem.c index 5585fa37..77143a7e 100644 --- a/src/daemon/https/tls/memmem.c +++ b/src/daemon/https/tls/memmem.c @@ -37,7 +37,7 @@ HAYSTACK. */ void * memmem (const void *haystack_start, size_t haystack_len, - const void *needle_start, size_t needle_len) + const void *needle_start, size_t needle_len) { /* Abstract memory is considered to be an array of 'unsigned char' values, not an array of 'char' values. See ISO C 99 section 6.2.6.1. */ @@ -62,11 +62,12 @@ memmem (const void *haystack_start, size_t haystack_len, { haystack = memchr (haystack, *needle, haystack_len); if (!haystack || __builtin_expect (needle_len == 1, 0)) - return (void *) haystack; + return (void *) haystack; haystack_len -= haystack - (const unsigned char *) haystack_start; if (haystack_len < needle_len) - return NULL; - return two_way_short_needle (haystack, haystack_len, needle, needle_len); + return NULL; + return two_way_short_needle (haystack, haystack_len, needle, + needle_len); } else return two_way_long_needle (haystack, haystack_len, needle, needle_len); diff --git a/src/daemon/https/tls/str-two-way.h b/src/daemon/https/tls/str-two-way.h index 69580736..29bb09f6 100644 --- a/src/daemon/https/tls/str-two-way.h +++ b/src/daemon/https/tls/str-two-way.h @@ -103,14 +103,14 @@ periodicity. */ static size_t critical_factorization (const unsigned char *needle, size_t needle_len, - size_t *period) + size_t * period) { /* Index of last byte of left half, or SIZE_MAX. */ size_t max_suffix, max_suffix_rev; - size_t j; /* Index into NEEDLE for current candidate suffix. */ - size_t k; /* Offset into current period. */ - size_t p; /* Intermediate period. */ - unsigned char a, b; /* Current comparison bytes. */ + size_t j; /* Index into NEEDLE for current candidate suffix. */ + size_t k; /* Offset into current period. */ + size_t p; /* Intermediate period. */ + unsigned char a, b; /* Current comparison bytes. */ /* Invariants: 0 <= j < NEEDLE_LEN - 1 @@ -119,7 +119,7 @@ critical_factorization (const unsigned char *needle, size_t needle_len, 1 <= p <= global period of NEEDLE p == global period of the substring NEEDLE[max_suffix{,_rev}+1...j] 1 <= k <= p - */ + */ /* Perform lexicographic search. */ max_suffix = SIZE_MAX; @@ -130,29 +130,29 @@ critical_factorization (const unsigned char *needle, size_t needle_len, a = CANON_ELEMENT (needle[j + k]); b = CANON_ELEMENT (needle[max_suffix + k]); if (a < b) - { - /* Suffix is smaller, period is entire prefix so far. */ - j += k; - k = 1; - p = j - max_suffix; - } + { + /* Suffix is smaller, period is entire prefix so far. */ + j += k; + k = 1; + p = j - max_suffix; + } else if (a == b) - { - /* Advance through repetition of the current period. */ - if (k != p) - ++k; - else - { - j += p; - k = 1; - } - } - else /* b < a */ - { - /* Suffix is larger, start over from current location. */ - max_suffix = j++; - k = p = 1; - } + { + /* Advance through repetition of the current period. */ + if (k != p) + ++k; + else + { + j += p; + k = 1; + } + } + else /* b < a */ + { + /* Suffix is larger, start over from current location. */ + max_suffix = j++; + k = p = 1; + } } *period = p; @@ -165,29 +165,29 @@ critical_factorization (const unsigned char *needle, size_t needle_len, a = CANON_ELEMENT (needle[j + k]); b = CANON_ELEMENT (needle[max_suffix_rev + k]); if (b < a) - { - /* Suffix is smaller, period is entire prefix so far. */ - j += k; - k = 1; - p = j - max_suffix_rev; - } + { + /* Suffix is smaller, period is entire prefix so far. */ + j += k; + k = 1; + p = j - max_suffix_rev; + } else if (a == b) - { - /* Advance through repetition of the current period. */ - if (k != p) - ++k; - else - { - j += p; - k = 1; - } - } - else /* a < b */ - { - /* Suffix is larger, start over from current location. */ - max_suffix_rev = j++; - k = p = 1; - } + { + /* Advance through repetition of the current period. */ + if (k != p) + ++k; + else + { + j += p; + k = 1; + } + } + else /* a < b */ + { + /* Suffix is larger, start over from current location. */ + max_suffix_rev = j++; + k = p = 1; + } } /* Choose the longer suffix. Return the first byte of the right @@ -210,12 +210,12 @@ critical_factorization (const unsigned char *needle, size_t needle_len, HAYSTACK_LEN - NEEDLE_LEN comparisons occur in searching. */ static RETURN_TYPE two_way_short_needle (const unsigned char *haystack, size_t haystack_len, - const unsigned char *needle, size_t needle_len) + const unsigned char *needle, size_t needle_len) { - size_t i; /* Index into current byte of NEEDLE. */ - size_t j; /* Index into current window of HAYSTACK. */ - size_t period; /* The period of the right half of needle. */ - size_t suffix; /* The index of the right half of needle. */ + size_t i; /* Index into current byte of NEEDLE. */ + size_t j; /* Index into current window of HAYSTACK. */ + size_t period; /* The period of the right half of needle. */ + size_t suffix; /* The index of the right half of needle. */ /* Factor the needle into two halves, such that the left half is smaller than the global period, and the right half is @@ -227,65 +227,65 @@ two_way_short_needle (const unsigned char *haystack, size_t haystack_len, if (CMP_FUNC (needle, needle + period, suffix) == 0) { /* Entire needle is periodic; a mismatch can only advance by the - period, so use memory to avoid rescanning known occurrences - of the period. */ + period, so use memory to avoid rescanning known occurrences + of the period. */ size_t memory = 0; j = 0; while (AVAILABLE (haystack, haystack_len, j, needle_len)) - { - /* Scan for matches in right half. */ - i = MAX (suffix, memory); - while (i < needle_len && (CANON_ELEMENT (needle[i]) - == CANON_ELEMENT (haystack[i + j]))) - ++i; - if (needle_len <= i) - { - /* Scan for matches in left half. */ - i = suffix - 1; - while (memory < i + 1 && (CANON_ELEMENT (needle[i]) - == CANON_ELEMENT (haystack[i + j]))) - --i; - if (i + 1 < memory + 1) - return (RETURN_TYPE) (haystack + j); - /* No match, so remember how many repetitions of period - on the right half were scanned. */ - j += period; - memory = needle_len - period; - } - else - { - j += i - suffix + 1; - memory = 0; - } - } + { + /* Scan for matches in right half. */ + i = MAX (suffix, memory); + while (i < needle_len && (CANON_ELEMENT (needle[i]) + == CANON_ELEMENT (haystack[i + j]))) + ++i; + if (needle_len <= i) + { + /* Scan for matches in left half. */ + i = suffix - 1; + while (memory < i + 1 && (CANON_ELEMENT (needle[i]) + == CANON_ELEMENT (haystack[i + j]))) + --i; + if (i + 1 < memory + 1) + return (RETURN_TYPE) (haystack + j); + /* No match, so remember how many repetitions of period + on the right half were scanned. */ + j += period; + memory = needle_len - period; + } + else + { + j += i - suffix + 1; + memory = 0; + } + } } else { /* The two halves of needle are distinct; no extra memory is - required, and any mismatch results in a maximal shift. */ + required, and any mismatch results in a maximal shift. */ period = MAX (suffix, needle_len - suffix) + 1; j = 0; while (AVAILABLE (haystack, haystack_len, j, needle_len)) - { - /* Scan for matches in right half. */ - i = suffix; - while (i < needle_len && (CANON_ELEMENT (needle[i]) - == CANON_ELEMENT (haystack[i + j]))) - ++i; - if (needle_len <= i) - { - /* Scan for matches in left half. */ - i = suffix - 1; - while (i != SIZE_MAX && (CANON_ELEMENT (needle[i]) - == CANON_ELEMENT (haystack[i + j]))) - --i; - if (i == SIZE_MAX) - return (RETURN_TYPE) (haystack + j); - j += period; - } - else - j += i - suffix + 1; - } + { + /* Scan for matches in right half. */ + i = suffix; + while (i < needle_len && (CANON_ELEMENT (needle[i]) + == CANON_ELEMENT (haystack[i + j]))) + ++i; + if (needle_len <= i) + { + /* Scan for matches in left half. */ + i = suffix - 1; + while (i != SIZE_MAX && (CANON_ELEMENT (needle[i]) + == CANON_ELEMENT (haystack[i + j]))) + --i; + if (i == SIZE_MAX) + return (RETURN_TYPE) (haystack + j); + j += period; + } + else + j += i - suffix + 1; + } } return NULL; } @@ -304,13 +304,13 @@ two_way_short_needle (const unsigned char *haystack, size_t haystack_len, sublinear performance is not possible. */ static RETURN_TYPE two_way_long_needle (const unsigned char *haystack, size_t haystack_len, - const unsigned char *needle, size_t needle_len) + const unsigned char *needle, size_t needle_len) { - size_t i; /* Index into current byte of NEEDLE. */ - size_t j; /* Index into current window of HAYSTACK. */ - size_t period; /* The period of the right half of needle. */ - size_t suffix; /* The index of the right half of needle. */ - size_t shift_table[1U << CHAR_BIT]; /* See below. */ + size_t i; /* Index into current byte of NEEDLE. */ + size_t j; /* Index into current window of HAYSTACK. */ + size_t period; /* The period of the right half of needle. */ + size_t suffix; /* The index of the right half of needle. */ + size_t shift_table[1U << CHAR_BIT]; /* See below. */ /* Factor the needle into two halves, such that the left half is smaller than the global period, and the right half is @@ -331,93 +331,93 @@ two_way_long_needle (const unsigned char *haystack, size_t haystack_len, if (CMP_FUNC (needle, needle + period, suffix) == 0) { /* Entire needle is periodic; a mismatch can only advance by the - period, so use memory to avoid rescanning known occurrences - of the period. */ + period, so use memory to avoid rescanning known occurrences + of the period. */ size_t memory = 0; size_t shift; j = 0; while (AVAILABLE (haystack, haystack_len, j, needle_len)) - { - /* Check the last byte first; if it does not match, then - shift to the next possible match location. */ - shift = shift_table[CANON_ELEMENT (haystack[j + needle_len - 1])]; - if (0 < shift) - { - if (memory && shift < period) - { - /* Since needle is periodic, but the last period has - a byte out of place, there can be no match until - after the mismatch. */ - shift = needle_len - period; - memory = 0; - } - j += shift; - continue; - } - /* Scan for matches in right half. The last byte has - already been matched, by virtue of the shift table. */ - i = MAX (suffix, memory); - while (i < needle_len - 1 && (CANON_ELEMENT (needle[i]) - == CANON_ELEMENT (haystack[i + j]))) - ++i; - if (needle_len - 1 <= i) - { - /* Scan for matches in left half. */ - i = suffix - 1; - while (memory < i + 1 && (CANON_ELEMENT (needle[i]) - == CANON_ELEMENT (haystack[i + j]))) - --i; - if (i + 1 < memory + 1) - return (RETURN_TYPE) (haystack + j); - /* No match, so remember how many repetitions of period - on the right half were scanned. */ - j += period; - memory = needle_len - period; - } - else - { - j += i - suffix + 1; - memory = 0; - } - } + { + /* Check the last byte first; if it does not match, then + shift to the next possible match location. */ + shift = shift_table[CANON_ELEMENT (haystack[j + needle_len - 1])]; + if (0 < shift) + { + if (memory && shift < period) + { + /* Since needle is periodic, but the last period has + a byte out of place, there can be no match until + after the mismatch. */ + shift = needle_len - period; + memory = 0; + } + j += shift; + continue; + } + /* Scan for matches in right half. The last byte has + already been matched, by virtue of the shift table. */ + i = MAX (suffix, memory); + while (i < needle_len - 1 && (CANON_ELEMENT (needle[i]) + == CANON_ELEMENT (haystack[i + j]))) + ++i; + if (needle_len - 1 <= i) + { + /* Scan for matches in left half. */ + i = suffix - 1; + while (memory < i + 1 && (CANON_ELEMENT (needle[i]) + == CANON_ELEMENT (haystack[i + j]))) + --i; + if (i + 1 < memory + 1) + return (RETURN_TYPE) (haystack + j); + /* No match, so remember how many repetitions of period + on the right half were scanned. */ + j += period; + memory = needle_len - period; + } + else + { + j += i - suffix + 1; + memory = 0; + } + } } else { /* The two halves of needle are distinct; no extra memory is - required, and any mismatch results in a maximal shift. */ + required, and any mismatch results in a maximal shift. */ size_t shift; period = MAX (suffix, needle_len - suffix) + 1; j = 0; while (AVAILABLE (haystack, haystack_len, j, needle_len)) - { - /* Check the last byte first; if it does not match, then - shift to the next possible match location. */ - shift = shift_table[CANON_ELEMENT (haystack[j + needle_len - 1])]; - if (0 < shift) - { - j += shift; - continue; - } - /* Scan for matches in right half. The last byte has - already been matched, by virtue of the shift table. */ - i = suffix; - while (i < needle_len - 1 && (CANON_ELEMENT (needle[i]) - == CANON_ELEMENT (haystack[i + j]))) - ++i; - if (needle_len - 1 <= i) - { - /* Scan for matches in left half. */ - i = suffix - 1; - while (i != SIZE_MAX && (CANON_ELEMENT (needle[i]) - == CANON_ELEMENT (haystack[i + j]))) - --i; - if (i == SIZE_MAX) - return (RETURN_TYPE) (haystack + j); - j += period; - } - else - j += i - suffix + 1; - } + { + /* Check the last byte first; if it does not match, then + shift to the next possible match location. */ + shift = shift_table[CANON_ELEMENT (haystack[j + needle_len - 1])]; + if (0 < shift) + { + j += shift; + continue; + } + /* Scan for matches in right half. The last byte has + already been matched, by virtue of the shift table. */ + i = suffix; + while (i < needle_len - 1 && (CANON_ELEMENT (needle[i]) + == CANON_ELEMENT (haystack[i + j]))) + ++i; + if (needle_len - 1 <= i) + { + /* Scan for matches in left half. */ + i = suffix - 1; + while (i != SIZE_MAX && (CANON_ELEMENT (needle[i]) + == CANON_ELEMENT (haystack[i + j]))) + --i; + if (i == SIZE_MAX) + return (RETURN_TYPE) (haystack + j); + j += period; + } + else + j += i - suffix + 1; + } } return NULL; } diff --git a/src/daemon/internal.c b/src/daemon/internal.c index 277e9699..b4cabe68 100644 --- a/src/daemon/internal.c +++ b/src/daemon/internal.c @@ -102,9 +102,7 @@ MHD_DLOG (const struct MHD_Daemon *daemon, const char *format, ...) if ((daemon->options & MHD_USE_DEBUG) == 0) return; va_start (va, format); - daemon->custom_error_log(daemon->custom_error_log_cls, - format, - va); + daemon->custom_error_log (daemon->custom_error_log_cls, format, va); va_end (va); } #endif diff --git a/src/daemon/internal.h b/src/daemon/internal.h index 9fc299e2..5fa38984 100644 --- a/src/daemon/internal.h +++ b/src/daemon/internal.h @@ -143,7 +143,7 @@ struct MHD_Response * Set to -1 if size is not known. */ size_t total_size; - + /** * Size of data. */ @@ -153,7 +153,7 @@ struct MHD_Response * Size of the data buffer. */ size_t data_buffer_size; - + /** * At what offset in the stream is the * beginning of data located? @@ -224,7 +224,7 @@ enum MHD_CONNECTION_STATE * rest. */ MHD_CONNECTION_FOOTER_PART_RECEIVED = MHD_CONNECTION_BODY_RECEIVED + 1, - + /** * 9: We received the entire footer. Wait for a response to be queued * and prepare the response headers. @@ -353,7 +353,7 @@ struct MHD_Connection * This is a linked list. */ struct MHD_Connection *next; - + /** * Reference to the MHD_Daemon struct. */ @@ -466,7 +466,7 @@ struct MHD_Connection * Size of write_buffer (in bytes). */ size_t write_buffer_size; - + /** * Offset where we are with sending from write_buffer. */ @@ -571,19 +571,19 @@ struct MHD_Connection * with respect to the current chunk (at what offset / position)? */ unsigned int current_chunk_offset; - + /** - * Handler used for processing read connection operations + * Handler used for processing read connection operations */ int (*read_handler) (struct MHD_Connection * connection); /** - * Handler used for processing write connection operations + * Handler used for processing write connection operations */ int (*write_handler) (struct MHD_Connection * connection); /** - * Handler used for processing idle connection operations + * Handler used for processing idle connection operations */ int (*idle_handler) (struct MHD_Connection * connection); @@ -615,7 +615,7 @@ struct MHD_Daemon * Callback function for all requests. */ MHD_AccessHandlerCallback default_handler; - + /** * Closure argument to default_handler. */ @@ -665,7 +665,7 @@ struct MHD_Daemon #if HAVE_MESSAGES /** - * Function for logging error messages (if we + * Function for logging error messages (if we * support error reporting). */ void (*custom_error_log) (void *cls, const char *fmt, va_list va); @@ -685,7 +685,7 @@ struct MHD_Daemon * Listen socket. */ int socket_fd; - + /** * Are we shutting down? */ @@ -731,12 +731,12 @@ struct MHD_Daemon enum MHD_GNUTLS_CredentialsType cred_type; /** - * Server x509 credentials + * Server x509 credentials */ MHD_gtls_cert_credentials_t x509_cred; /** - * Cipher priority cache + * Cipher priority cache */ MHD_gnutls_priority_t priority_cache; diff --git a/src/include/microhttpd.h b/src/include/microhttpd.h index 3ff2e4b9..8b7960ea 100644 --- a/src/include/microhttpd.h +++ b/src/include/microhttpd.h @@ -925,10 +925,9 @@ MHD_set_connection_value (struct MHD_Connection *connection, * @param key the header to look for * @return NULL if no such item was found */ -const char * -MHD_lookup_connection_value (struct MHD_Connection *connection, - enum MHD_ValueKind kind, - const char *key); +const char *MHD_lookup_connection_value (struct MHD_Connection *connection, + enum MHD_ValueKind kind, + const char *key); /** * Queue a response to be transmitted to the client (as soon as diff --git a/src/testcurl/daemontest_parse_cookies.c b/src/testcurl/daemontest_parse_cookies.c index 642aaedc..13f4ad12 100644 --- a/src/testcurl/daemontest_parse_cookies.c +++ b/src/testcurl/daemontest_parse_cookies.c @@ -82,30 +82,18 @@ ahc_echo (void *cls, *unused = NULL; ret = 0; - hdr = MHD_lookup_connection_value (connection, - MHD_COOKIE_KIND, - "name1"); - if ( (hdr == NULL) || - (0 != strcmp(hdr, "var1")) ) - abort(); - hdr = MHD_lookup_connection_value (connection, - MHD_COOKIE_KIND, - "name2"); - if ( (hdr == NULL) || - (0 != strcmp(hdr, "var2")) ) - abort(); - hdr = MHD_lookup_connection_value (connection, - MHD_COOKIE_KIND, - "name3"); - if ( (hdr == NULL) || - (0 != strcmp(hdr, "")) ) - abort(); - hdr = MHD_lookup_connection_value (connection, - MHD_COOKIE_KIND, - "name4"); - if ( (hdr == NULL) || - (0 != strcmp(hdr, "var4 with spaces")) ) - abort(); + hdr = MHD_lookup_connection_value (connection, MHD_COOKIE_KIND, "name1"); + if ((hdr == NULL) || (0 != strcmp (hdr, "var1"))) + abort (); + hdr = MHD_lookup_connection_value (connection, MHD_COOKIE_KIND, "name2"); + if ((hdr == NULL) || (0 != strcmp (hdr, "var2"))) + abort (); + hdr = MHD_lookup_connection_value (connection, MHD_COOKIE_KIND, "name3"); + if ((hdr == NULL) || (0 != strcmp (hdr, ""))) + abort (); + hdr = MHD_lookup_connection_value (connection, MHD_COOKIE_KIND, "name4"); + if ((hdr == NULL) || (0 != strcmp (hdr, "var4 with spaces"))) + abort (); response = MHD_create_response_from_data (strlen (url), (void *) url, MHD_NO, MHD_YES); ret = MHD_queue_response (connection, MHD_HTTP_OK, response); @@ -145,12 +133,12 @@ testExternalGet () curl_easy_setopt (c, CURLOPT_URL, "http://localhost:21080/hello_world"); curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); - curl_easy_setopt (c, CURLOPT_FAILONERROR, 1); + curl_easy_setopt (c, CURLOPT_FAILONERROR, 1); /* note that the string below intentionally uses the various ways cookies can be specified to exercise the parser! Do not change! */ curl_easy_setopt (c, CURLOPT_COOKIE, - "name1=var1; name2=var2,name3 ;name4=\"var4 with spaces\";"); + "name1=var1; name2=var2,name3 ;name4=\"var4 with spaces\";"); if (oneone) curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); else @@ -158,8 +146,8 @@ testExternalGet () curl_easy_setopt (c, CURLOPT_TIMEOUT, 150L); curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT, 15L); /* NOTE: use of CONNECTTIMEOUT without also - setting NOSIGNAL results in really weird - crashes on my system! */ + setting NOSIGNAL results in really weird + crashes on my system! */ curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1); diff --git a/src/testcurl/daemontest_process_headers.c b/src/testcurl/daemontest_process_headers.c index 77b56306..5ab0ab1b 100644 --- a/src/testcurl/daemontest_process_headers.c +++ b/src/testcurl/daemontest_process_headers.c @@ -57,17 +57,13 @@ copyBuffer (void *ptr, size_t size, size_t nmemb, void *ctx) return size * nmemb; } -static int -kv_cb(void * cls, - enum MHD_ValueKind kind, - const char * key, - const char * value) +static int +kv_cb (void *cls, enum MHD_ValueKind kind, const char *key, const char *value) { - if ( (0 == strcmp(key, MHD_HTTP_HEADER_HOST)) && - (0 == strcmp(value, "localhost:21080")) && - (kind == MHD_HEADER_KIND) ) + if ((0 == strcmp (key, MHD_HTTP_HEADER_HOST)) && + (0 == strcmp (value, "localhost:21080")) && (kind == MHD_HEADER_KIND)) { - *((int*) cls) = 1; + *((int *) cls) = 1; return MHD_NO; } return MHD_YES; @@ -97,61 +93,41 @@ ahc_echo (void *cls, } *unused = NULL; ret = 0; - MHD_get_connection_values (connection, - MHD_HEADER_KIND, - &kv_cb, - &ret); + MHD_get_connection_values (connection, MHD_HEADER_KIND, &kv_cb, &ret); if (ret != 1) - abort(); - hdr = MHD_lookup_connection_value (connection, - MHD_HEADER_KIND, - "NotFound"); + abort (); + hdr = MHD_lookup_connection_value (connection, MHD_HEADER_KIND, "NotFound"); if (hdr != NULL) - abort(); - hdr = MHD_lookup_connection_value (connection, - MHD_HEADER_KIND, - MHD_HTTP_HEADER_ACCEPT); - if ( (hdr == NULL) || - (0 != strcmp(hdr, "*/*")) ) - abort(); - hdr = MHD_lookup_connection_value (connection, - MHD_HEADER_KIND, - MHD_HTTP_HEADER_HOST); - if ( (hdr == NULL) || - (0 != strcmp(hdr, "localhost:21080")) ) - abort(); - MHD_set_connection_value (connection, - MHD_HEADER_KIND, - "FakeHeader", - "NowPresent"); - hdr = MHD_lookup_connection_value (connection, - MHD_HEADER_KIND, - "FakeHeader"); - if ( (hdr == NULL) || - (0 != strcmp(hdr, "NowPresent")) ) - abort(); + abort (); + hdr = MHD_lookup_connection_value (connection, + MHD_HEADER_KIND, MHD_HTTP_HEADER_ACCEPT); + if ((hdr == NULL) || (0 != strcmp (hdr, "*/*"))) + abort (); + hdr = MHD_lookup_connection_value (connection, + MHD_HEADER_KIND, MHD_HTTP_HEADER_HOST); + if ((hdr == NULL) || (0 != strcmp (hdr, "localhost:21080"))) + abort (); + MHD_set_connection_value (connection, + MHD_HEADER_KIND, "FakeHeader", "NowPresent"); + hdr = MHD_lookup_connection_value (connection, + MHD_HEADER_KIND, "FakeHeader"); + if ((hdr == NULL) || (0 != strcmp (hdr, "NowPresent"))) + abort (); response = MHD_create_response_from_data (strlen (url), (void *) url, MHD_NO, MHD_YES); - MHD_add_response_header (response, - "MyHeader", - "MyValue"); + MHD_add_response_header (response, "MyHeader", "MyValue"); hdr = MHD_get_response_header (response, "MyHeader"); if (0 != strcmp ("MyValue", hdr)) - abort(); - MHD_add_response_header (response, - "MyHeader", - "MyValueToo"); - if (MHD_YES != - MHD_del_response_header (response, - "MyHeader", - "MyValue")) - abort(); + abort (); + MHD_add_response_header (response, "MyHeader", "MyValueToo"); + if (MHD_YES != MHD_del_response_header (response, "MyHeader", "MyValue")) + abort (); hdr = MHD_get_response_header (response, "MyHeader"); if (0 != strcmp ("MyValueToo", hdr)) - abort(); + abort (); if (1 != MHD_get_response_headers (response, NULL, NULL)) - abort(); + abort (); ret = MHD_queue_response (connection, MHD_HTTP_OK, response); MHD_destroy_response (response); if (ret == MHD_NO) @@ -297,8 +273,8 @@ testExternalGet () curl_easy_setopt (c, CURLOPT_TIMEOUT, 150L); curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT, 15L); /* NOTE: use of CONNECTTIMEOUT without also - setting NOSIGNAL results in really weird - crashes on my system! */ + setting NOSIGNAL results in really weird + crashes on my system! */ curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1); diff --git a/src/testcurl/https/bug-test.c b/src/testcurl/https/bug-test.c index 8bbf7d61..34680b5f 100644 --- a/src/testcurl/https/bug-test.c +++ b/src/testcurl/https/bug-test.c @@ -151,7 +151,7 @@ test_daemon_get (FILE * test_fd, char *cipher_suite, int proto_version) fprintf (stderr, MHD_E_MEM); return -1; } - if (getcwd (doc_path, doc_path_len) == NULL) + if (getcwd (doc_path, doc_path_len) == NULL) { fclose (test_fd); free (doc_path); diff --git a/src/testcurl/https/mhds_multi_daemon_test.c b/src/testcurl/https/mhds_multi_daemon_test.c index d137a6c8..b462cdd7 100644 --- a/src/testcurl/https/mhds_multi_daemon_test.c +++ b/src/testcurl/https/mhds_multi_daemon_test.c @@ -147,7 +147,7 @@ test_daemon_get (FILE * test_fd, char *cipher_suite, int proto_version, fprintf (stderr, MHD_E_MEM); return -1; } - if (getcwd (doc_path, doc_path_len) == NULL) + if (getcwd (doc_path, doc_path_len) == NULL) { fclose (test_fd); free (doc_path); diff --git a/src/testcurl/https/tls_authentication_test.c b/src/testcurl/https/tls_authentication_test.c index 4084506f..976044e0 100644 --- a/src/testcurl/https/tls_authentication_test.c +++ b/src/testcurl/https/tls_authentication_test.c @@ -148,7 +148,7 @@ test_daemon_get (FILE * test_fd, char *cipher_suite, int proto_version) fprintf (stderr, MHD_E_MEM); return -1; } - if (getcwd (doc_path, doc_path_len) == NULL) + if (getcwd (doc_path, doc_path_len) == NULL) { fclose (test_fd); free (doc_path); diff --git a/src/testcurl/https/tls_daemon_options_test.c b/src/testcurl/https/tls_daemon_options_test.c index a7ed6e56..a0d8af97 100644 --- a/src/testcurl/https/tls_daemon_options_test.c +++ b/src/testcurl/https/tls_daemon_options_test.c @@ -303,9 +303,9 @@ teardown (struct MHD_Daemon *d) /* TODO test_wrap: change sig to (setup_func, test, va_list test_arg) & move to test_util.c */ static int test_wrap (char *test_name, int - (*test_function) (FILE * test_fd, char *cipher_suite, int proto_version), - FILE * test_fd, int daemon_flags, char *cipher_suite, - int proto_version, ...) + (*test_function) (FILE * test_fd, char *cipher_suite, + int proto_version), FILE * test_fd, + int daemon_flags, char *cipher_suite, int proto_version, ...) { int ret; va_list arg_list; diff --git a/src/testcurl/https/tls_thread_mode_test.c b/src/testcurl/https/tls_thread_mode_test.c index 326be74a..a2f0de87 100644 --- a/src/testcurl/https/tls_thread_mode_test.c +++ b/src/testcurl/https/tls_thread_mode_test.c @@ -1,17 +1,17 @@ /* This file is part of libmicrohttpd (C) 2007 Christian Grothoff - + libmicrohttpd is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. - + libmicrohttpd is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License along with libmicrohttpd; see the file COPYING. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, @@ -23,8 +23,8 @@ * @brief Testcase for libmicrohttpd HTTPS GET operations * @author Sagie Amir * @author Christian Grothoff - * - * TODO: add test for external select! + * + * TODO: add test for external select! */ #include "platform.h" @@ -268,7 +268,7 @@ https_transfer_thread_adapter (void *args) /* time spread incomming requests */ usleep ((useconds_t) 10.0 * ((double) rand ()) / ((double) RAND_MAX)); ret = test_https_transfer (cargs->test_fd, - cargs->cipher_suite, cargs->proto_version); + cargs->cipher_suite, cargs->proto_version); if (ret == 0) return NULL; return &nonnull; @@ -326,9 +326,9 @@ teardown (struct MHD_Daemon *d) /* TODO test_wrap: change sig to (setup_func, test, va_list test_arg) & move to test_util.c */ static int test_wrap (char *test_name, int - (*test_function) (FILE * test_fd, char *cipher_suite, int proto_version), - FILE * test_fd, int daemon_flags, char *cipher_suite, - int proto_version, ...) + (*test_function) (FILE * test_fd, char *cipher_suite, + int proto_version), FILE * test_fd, + int daemon_flags, char *cipher_suite, int proto_version, ...) { int ret; va_list arg_list; @@ -367,14 +367,15 @@ test_wrap (char *test_name, int */ static int test_single_client (FILE * test_fd, char *cipher_suite, - int curl_proto_version) + int curl_proto_version) { void *client_thread_ret; - struct https_test_data client_args = {test_fd, cipher_suite, curl_proto_version}; + struct https_test_data client_args = + { test_fd, cipher_suite, curl_proto_version }; client_thread_ret = https_transfer_thread_adapter (&client_args); if (client_thread_ret != NULL) - return -1; + return -1; return 0; } @@ -388,18 +389,20 @@ test_single_client (FILE * test_fd, char *cipher_suite, */ static int test_parallel_clients (FILE * test_fd, char *cipher_suite, - int curl_proto_version) + int curl_proto_version) { int i; int client_count = 3; void *client_thread_ret; pthread_t client_arr[client_count]; - struct https_test_data client_args = {test_fd, cipher_suite, curl_proto_version}; + struct https_test_data client_args = + { test_fd, cipher_suite, curl_proto_version }; for (i = 0; i < client_count; ++i) { if (pthread_create (&client_arr[i], NULL, - (void * ) &https_transfer_thread_adapter, &client_args) != 0) + (void *) &https_transfer_thread_adapter, + &client_args) != 0) { fprintf (stderr, "Error: failed to spawn test client threads.\n"); return -1; @@ -410,8 +413,8 @@ test_parallel_clients (FILE * test_fd, char *cipher_suite, for (i = 0; i < client_count; ++i) { if ((pthread_join (client_arr[i], &client_thread_ret) != 0) || - (client_thread_ret != NULL) ) - return -1; + (client_thread_ret != NULL)) + return -1; } return 0; @@ -429,7 +432,7 @@ main (int argc, char *const *argv) srand (iseed); if (curl_check_version (MHD_REQ_CURL_VERSION)) - return -1; + return -1; if ((test_fd = setupTestFile ()) == NULL) { @@ -444,34 +447,34 @@ main (int argc, char *const *argv) } errorCount += - test_wrap ("multi threaded daemon, single client", &test_single_client, test_fd, - MHD_USE_SSL | MHD_USE_DEBUG, "AES256-SHA", + test_wrap ("multi threaded daemon, single client", &test_single_client, + test_fd, MHD_USE_SSL | MHD_USE_DEBUG, "AES256-SHA", CURL_SSLVERSION_TLSv1, MHD_OPTION_HTTPS_MEM_KEY, srv_key_pem, MHD_OPTION_HTTPS_MEM_CERT, srv_self_signed_cert_pem, MHD_OPTION_END); errorCount += - test_wrap ("single threaded daemon, single client", &test_single_client, test_fd, - MHD_USE_SELECT_INTERNALLY | - MHD_USE_SSL | MHD_USE_DEBUG, "AES256-SHA", - CURL_SSLVERSION_TLSv1, MHD_OPTION_HTTPS_MEM_KEY, srv_key_pem, - MHD_OPTION_HTTPS_MEM_CERT, srv_self_signed_cert_pem, - MHD_OPTION_END); + test_wrap ("single threaded daemon, single client", &test_single_client, + test_fd, + MHD_USE_SELECT_INTERNALLY | MHD_USE_SSL | MHD_USE_DEBUG, + "AES256-SHA", CURL_SSLVERSION_TLSv1, MHD_OPTION_HTTPS_MEM_KEY, + srv_key_pem, MHD_OPTION_HTTPS_MEM_CERT, + srv_self_signed_cert_pem, MHD_OPTION_END); errorCount += - test_wrap ("multi threaded daemon, parallel client", &test_parallel_clients, test_fd, - MHD_USE_SSL | MHD_USE_DEBUG, "AES256-SHA", - CURL_SSLVERSION_TLSv1, MHD_OPTION_HTTPS_MEM_KEY, srv_key_pem, - MHD_OPTION_HTTPS_MEM_CERT, srv_self_signed_cert_pem, - MHD_OPTION_END); + test_wrap ("multi threaded daemon, parallel client", + &test_parallel_clients, test_fd, MHD_USE_SSL | MHD_USE_DEBUG, + "AES256-SHA", CURL_SSLVERSION_TLSv1, MHD_OPTION_HTTPS_MEM_KEY, + srv_key_pem, MHD_OPTION_HTTPS_MEM_CERT, + srv_self_signed_cert_pem, MHD_OPTION_END); errorCount += - test_wrap ("single threaded daemon, parallel clients", &test_parallel_clients, test_fd, - MHD_USE_SELECT_INTERNALLY | - MHD_USE_SSL | MHD_USE_DEBUG, "AES256-SHA", - CURL_SSLVERSION_TLSv1, MHD_OPTION_HTTPS_MEM_KEY, srv_key_pem, - MHD_OPTION_HTTPS_MEM_CERT, srv_self_signed_cert_pem, - MHD_OPTION_END); + test_wrap ("single threaded daemon, parallel clients", + &test_parallel_clients, test_fd, + MHD_USE_SELECT_INTERNALLY | MHD_USE_SSL | MHD_USE_DEBUG, + "AES256-SHA", CURL_SSLVERSION_TLSv1, MHD_OPTION_HTTPS_MEM_KEY, + srv_key_pem, MHD_OPTION_HTTPS_MEM_CERT, + srv_self_signed_cert_pem, MHD_OPTION_END); if (errorCount != 0) fprintf (stderr, "Failed test: %s.\n", argv[0]); -- cgit v1.2.3