diff options
author | Christian Grothoff <christian@grothoff.org> | 2008-12-27 07:49:35 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2008-12-27 07:49:35 +0000 |
commit | 03573e80f7f70b8f37af1adc7fdfa0ac2bf1b5af (patch) | |
tree | 2c058ebea04a64cf7918a596007d714663690564 | |
parent | ccfcc31ac1a4d4d37eb8cf6c83ffc2868c6cfcca (diff) | |
download | libmicrohttpd-03573e80f7f70b8f37af1adc7fdfa0ac2bf1b5af.tar.gz libmicrohttpd-03573e80f7f70b8f37af1adc7fdfa0ac2bf1b5af.zip |
indent
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, | |||
288 | connection->socket_fd = -1; | 288 | connection->socket_fd = -1; |
289 | connection->state = MHD_CONNECTION_CLOSED; | 289 | connection->state = MHD_CONNECTION_CLOSED; |
290 | if (connection->daemon->notify_completed != NULL) | 290 | if (connection->daemon->notify_completed != NULL) |
291 | connection->daemon->notify_completed (connection-> | 291 | connection->daemon->notify_completed (connection->daemon-> |
292 | daemon->notify_completed_cls, | 292 | notify_completed_cls, connection, |
293 | connection, | ||
294 | &connection->client_context, | 293 | &connection->client_context, |
295 | termination_code); | 294 | termination_code); |
296 | } | 295 | } |
@@ -976,35 +975,29 @@ parse_cookie_header (struct MHD_Connection *connection) | |||
976 | while (pos != NULL) | 975 | while (pos != NULL) |
977 | { | 976 | { |
978 | while (*pos == ' ') | 977 | while (*pos == ' ') |
979 | pos++; /* skip spaces */ | 978 | pos++; /* skip spaces */ |
980 | 979 | ||
981 | sce = pos; | 980 | sce = pos; |
982 | while ( ( (*sce) != '\0') && | 981 | while (((*sce) != '\0') && |
983 | ( (*sce) != ',') && | 982 | ((*sce) != ',') && ((*sce) != ';') && ((*sce) != '=')) |
984 | ( (*sce) != ';') && | 983 | sce++; |
985 | ( (*sce) != '=') ) | ||
986 | sce++; | ||
987 | /* remove tailing whitespace (if any) from key */ | 984 | /* remove tailing whitespace (if any) from key */ |
988 | ekill = sce - 1; | 985 | ekill = sce - 1; |
989 | while ( (*ekill == ' ') && | 986 | while ((*ekill == ' ') && (ekill >= pos)) |
990 | (ekill >= pos) ) | 987 | *(ekill--) = '\0'; |
991 | *(ekill--) = '\0'; | ||
992 | old = *sce; | 988 | old = *sce; |
993 | *sce = '\0'; | 989 | *sce = '\0'; |
994 | if (old != '=') | 990 | if (old != '=') |
995 | { | 991 | { |
996 | /* value part omitted, use empty string... */ | 992 | /* value part omitted, use empty string... */ |
997 | if (MHD_NO == | 993 | if (MHD_NO == |
998 | connection_add_header (connection, | 994 | connection_add_header (connection, pos, "", MHD_COOKIE_KIND)) |
999 | pos, | 995 | return MHD_NO; |
1000 | "", | 996 | if (old == '\0') |
1001 | MHD_COOKIE_KIND)) | 997 | break; |
1002 | return MHD_NO; | 998 | pos = sce + 1; |
1003 | if (old == '\0') | 999 | continue; |
1004 | break; | 1000 | } |
1005 | pos = sce + 1; | ||
1006 | continue; | ||
1007 | } | ||
1008 | equals = sce + 1; | 1001 | equals = sce + 1; |
1009 | quotes = 0; | 1002 | quotes = 0; |
1010 | semicolon = equals; | 1003 | semicolon = equals; |
@@ -1068,9 +1061,8 @@ parse_initial_message_line (struct MHD_Connection *connection, char *line) | |||
1068 | if (connection->daemon->uri_log_callback != NULL) | 1061 | if (connection->daemon->uri_log_callback != NULL) |
1069 | connection->client_context | 1062 | connection->client_context |
1070 | = | 1063 | = |
1071 | connection->daemon->uri_log_callback (connection-> | 1064 | connection->daemon->uri_log_callback (connection->daemon-> |
1072 | daemon->uri_log_callback_cls, | 1065 | uri_log_callback_cls, uri); |
1073 | uri); | ||
1074 | args = strstr (uri, "?"); | 1066 | args = strstr (uri, "?"); |
1075 | if (args != NULL) | 1067 | if (args != NULL) |
1076 | { | 1068 | { |
@@ -1218,8 +1210,8 @@ call_connection_handler (struct MHD_Connection *connection) | |||
1218 | } | 1210 | } |
1219 | used = processed; | 1211 | used = processed; |
1220 | if (MHD_NO == | 1212 | if (MHD_NO == |
1221 | connection->daemon->default_handler (connection-> | 1213 | connection->daemon->default_handler (connection->daemon-> |
1222 | daemon->default_handler_cls, | 1214 | default_handler_cls, |
1223 | connection, connection->url, | 1215 | connection, connection->url, |
1224 | connection->method, | 1216 | connection->method, |
1225 | connection->version, | 1217 | connection->version, |
@@ -1620,11 +1612,9 @@ MHD_connection_handle_write (struct MHD_Connection *connection) | |||
1620 | case MHD_CONNECTION_CONTINUE_SENDING: | 1612 | case MHD_CONNECTION_CONTINUE_SENDING: |
1621 | ret = connection->send_cls (connection, | 1613 | ret = connection->send_cls (connection, |
1622 | &HTTP_100_CONTINUE | 1614 | &HTTP_100_CONTINUE |
1623 | [connection-> | 1615 | [connection->continue_message_write_offset], |
1624 | continue_message_write_offset], | ||
1625 | strlen (HTTP_100_CONTINUE) - | 1616 | strlen (HTTP_100_CONTINUE) - |
1626 | connection-> | 1617 | connection->continue_message_write_offset); |
1627 | continue_message_write_offset); | ||
1628 | if (ret < 0) | 1618 | if (ret < 0) |
1629 | { | 1619 | { |
1630 | if (errno == EINTR) | 1620 | if (errno == EINTR) |
@@ -1674,12 +1664,12 @@ MHD_connection_handle_write (struct MHD_Connection *connection) | |||
1674 | { | 1664 | { |
1675 | ret = MHD__gnutls_record_send (connection->tls_session, | 1665 | ret = MHD__gnutls_record_send (connection->tls_session, |
1676 | &connection->response->data | 1666 | &connection->response->data |
1677 | [connection->response_write_position | 1667 | [connection-> |
1678 | - response->data_start], | ||
1679 | response->data_size - | ||
1680 | (connection-> | ||
1681 | response_write_position - | 1668 | response_write_position - |
1682 | response->data_start)); | 1669 | response->data_start], |
1670 | response->data_size - | ||
1671 | (connection->response_write_position | ||
1672 | - response->data_start)); | ||
1683 | } | 1673 | } |
1684 | else | 1674 | else |
1685 | #endif | 1675 | #endif |
@@ -1749,10 +1739,10 @@ MHD_connection_handle_write (struct MHD_Connection *connection) | |||
1749 | case MHD_TLS_HANDSHAKE_FAILED: | 1739 | case MHD_TLS_HANDSHAKE_FAILED: |
1750 | EXTRA_CHECK (0); | 1740 | EXTRA_CHECK (0); |
1751 | break; | 1741 | break; |
1752 | default: | 1742 | default: |
1753 | EXTRA_CHECK (0); | 1743 | EXTRA_CHECK (0); |
1754 | connection_close_error (connection); | 1744 | connection_close_error (connection); |
1755 | return MHD_NO; | 1745 | return MHD_NO; |
1756 | } | 1746 | } |
1757 | break; | 1747 | break; |
1758 | } | 1748 | } |
@@ -2043,8 +2033,8 @@ MHD_connection_handle_idle (struct MHD_Connection *connection) | |||
2043 | #endif | 2033 | #endif |
2044 | MHD_destroy_response (connection->response); | 2034 | MHD_destroy_response (connection->response); |
2045 | if (connection->daemon->notify_completed != NULL) | 2035 | if (connection->daemon->notify_completed != NULL) |
2046 | connection->daemon->notify_completed (connection-> | 2036 | connection->daemon->notify_completed (connection->daemon-> |
2047 | daemon->notify_completed_cls, | 2037 | notify_completed_cls, |
2048 | connection, | 2038 | connection, |
2049 | &connection->client_context, | 2039 | &connection->client_context, |
2050 | MHD_REQUEST_TERMINATED_COMPLETED_OK); | 2040 | 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, | |||
58 | { | 58 | { |
59 | #if HTTPS_SUPPORT | 59 | #if HTTPS_SUPPORT |
60 | case MHD_CONNECTION_INFO_CIPHER_ALGO: | 60 | case MHD_CONNECTION_INFO_CIPHER_ALGO: |
61 | return (const union MHD_ConnectionInfo *) &connection->tls_session-> | 61 | return (const union MHD_ConnectionInfo *) &connection-> |
62 | security_parameters.read_bulk_cipher_algorithm; | 62 | tls_session->security_parameters.read_bulk_cipher_algorithm; |
63 | case MHD_CONNECTION_INFO_PROTOCOL: | 63 | case MHD_CONNECTION_INFO_PROTOCOL: |
64 | return (const union MHD_ConnectionInfo *) &connection->tls_session-> | 64 | return (const union MHD_ConnectionInfo *) &connection-> |
65 | security_parameters.version; | 65 | tls_session->security_parameters.version; |
66 | #endif | 66 | #endif |
67 | default: | 67 | default: |
68 | return NULL; | 68 | return NULL; |
@@ -246,9 +246,8 @@ MHD_tls_connection_handle_read (struct MHD_Connection *connection) | |||
246 | MHD_DLOG (connection->daemon, | 246 | MHD_DLOG (connection->daemon, |
247 | "Received TLS alert: %s\n", | 247 | "Received TLS alert: %s\n", |
248 | MHD__gnutls_alert_get_name ((int) | 248 | MHD__gnutls_alert_get_name ((int) |
249 | connection-> | 249 | connection->tls_session-> |
250 | tls_session->internals. | 250 | internals.last_alert)); |
251 | last_alert)); | ||
252 | #endif | 251 | #endif |
253 | return MHD_YES; | 252 | return MHD_YES; |
254 | } | 253 | } |
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, | |||
835 | retVal->pool_size = MHD_POOL_SIZE_DEFAULT; | 835 | retVal->pool_size = MHD_POOL_SIZE_DEFAULT; |
836 | retVal->connection_timeout = 0; /* no timeout */ | 836 | retVal->connection_timeout = 0; /* no timeout */ |
837 | #if HAVE_MESSAGES | 837 | #if HAVE_MESSAGES |
838 | retVal->custom_error_log = (void(*)(void*,const char *,va_list)) &vfprintf; | 838 | retVal->custom_error_log = |
839 | (void (*)(void *, const char *, va_list)) &vfprintf; | ||
839 | retVal->custom_error_log_cls = stderr; | 840 | retVal->custom_error_log_cls = stderr; |
840 | #endif | 841 | #endif |
841 | #if HTTPS_SUPPORT | 842 | #if HTTPS_SUPPORT |
@@ -896,13 +897,14 @@ MHD_start_daemon_va (unsigned int options, | |||
896 | va_arg (ap, const int *)); | 897 | va_arg (ap, const int *)); |
897 | break; | 898 | break; |
898 | #endif | 899 | #endif |
899 | case MHD_OPTION_EXTERNAL_LOGGER: | 900 | case MHD_OPTION_EXTERNAL_LOGGER: |
900 | #if HAVE_MESSAGES | 901 | #if HAVE_MESSAGES |
901 | retVal->custom_error_log = va_arg(ap, void (*)(void*cls, const char *, va_list)); | 902 | retVal->custom_error_log = |
902 | retVal->custom_error_log_cls = va_arg(ap, void *); | 903 | va_arg (ap, void (*)(void *cls, const char *, va_list)); |
904 | retVal->custom_error_log_cls = va_arg (ap, void *); | ||
903 | #else | 905 | #else |
904 | va_arg(ap, void (*)(void*cls, const char *,...)); | 906 | va_arg (ap, void (*)(void *cls, const char *, ...)); |
905 | va_arg(ap, void *); | 907 | va_arg (ap, void *); |
906 | #endif | 908 | #endif |
907 | default: | 909 | default: |
908 | #if HAVE_MESSAGES | 910 | #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, | |||
168 | } | 168 | } |
169 | 169 | ||
170 | bits = | 170 | bits = |
171 | MHD__gnutls_mpi_get_nbits (session->internals. | 171 | MHD__gnutls_mpi_get_nbits (session->internals.selected_cert_list[0]. |
172 | selected_cert_list[0].params[0]); | 172 | params[0]); |
173 | 173 | ||
174 | if (MHD_gtls_cipher_suite_get_kx_algo | 174 | if (MHD_gtls_cipher_suite_get_kx_algo |
175 | (&session->security_parameters.current_cipher_suite) | 175 | (&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, | |||
183 | for (i = 0; i < len; i++) | 183 | for (i = 0; i < len; i++) |
184 | { | 184 | { |
185 | data[i + 1] = | 185 | data[i + 1] = |
186 | MHD__gnutls_cert_type2num (session->internals.priorities. | 186 | MHD__gnutls_cert_type2num (session->internals. |
187 | cert_type.priority[i]); | 187 | priorities.cert_type.priority[i]); |
188 | } | 188 | } |
189 | return len + 1; | 189 | return len + 1; |
190 | } | 190 | } |
@@ -203,8 +203,8 @@ MHD_gtls_cert_type_send_params (MHD_gtls_session_t session, opaque * data, | |||
203 | } | 203 | } |
204 | 204 | ||
205 | data[0] = | 205 | data[0] = |
206 | MHD__gnutls_cert_type2num (session->security_parameters. | 206 | MHD__gnutls_cert_type2num (session-> |
207 | cert_type); | 207 | security_parameters.cert_type); |
208 | return len; | 208 | return len; |
209 | } | 209 | } |
210 | 210 | ||
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, | |||
121 | } | 121 | } |
122 | 122 | ||
123 | data[0] = | 123 | data[0] = |
124 | (uint8_t) MHD_gtls_mre_record2num (session-> | 124 | (uint8_t) MHD_gtls_mre_record2num (session->internals. |
125 | internals.proposed_record_size); | 125 | proposed_record_size); |
126 | return len; | 126 | return len; |
127 | } | 127 | } |
128 | 128 | ||
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, | |||
118 | case 0: /* NAME_DNS */ | 118 | case 0: /* NAME_DNS */ |
119 | if (len <= MAX_SERVER_NAME_SIZE) | 119 | if (len <= MAX_SERVER_NAME_SIZE) |
120 | { | 120 | { |
121 | memcpy (session->security_parameters.extensions.server_names[i]. | 121 | memcpy (session->security_parameters.extensions. |
122 | name, p, len); | 122 | server_names[i].name, p, len); |
123 | session->security_parameters.extensions. | 123 | session->security_parameters.extensions.server_names[i]. |
124 | server_names[i].name_length = len; | 124 | name_length = len; |
125 | session->security_parameters.extensions.server_names[i].type = | 125 | session->security_parameters.extensions.server_names[i].type = |
126 | GNUTLS_NAME_DNS; | 126 | GNUTLS_NAME_DNS; |
127 | break; | 127 | break; |
@@ -163,8 +163,8 @@ MHD_gtls_server_name_send_params (MHD_gtls_session_t session, | |||
163 | /* count the total size | 163 | /* count the total size |
164 | */ | 164 | */ |
165 | len = | 165 | len = |
166 | session->security_parameters.extensions. | 166 | session->security_parameters.extensions.server_names[i]. |
167 | server_names[i].name_length; | 167 | name_length; |
168 | 168 | ||
169 | /* uint8_t + uint16_t + size | 169 | /* uint8_t + uint16_t + size |
170 | */ | 170 | */ |
@@ -183,14 +183,14 @@ MHD_gtls_server_name_send_params (MHD_gtls_session_t session, | |||
183 | i < session->security_parameters.extensions.server_names_size; i++) | 183 | i < session->security_parameters.extensions.server_names_size; i++) |
184 | { | 184 | { |
185 | 185 | ||
186 | switch (session->security_parameters.extensions.server_names[i]. | 186 | switch (session->security_parameters.extensions. |
187 | type) | 187 | server_names[i].type) |
188 | { | 188 | { |
189 | case GNUTLS_NAME_DNS: | 189 | case GNUTLS_NAME_DNS: |
190 | 190 | ||
191 | len = | 191 | len = |
192 | session->security_parameters.extensions.server_names[i]. | 192 | session->security_parameters.extensions. |
193 | name_length; | 193 | server_names[i].name_length; |
194 | if (len == 0) | 194 | if (len == 0) |
195 | break; | 195 | break; |
196 | 196 | ||
@@ -208,8 +208,8 @@ MHD_gtls_server_name_send_params (MHD_gtls_session_t session, | |||
208 | p += 2; | 208 | p += 2; |
209 | 209 | ||
210 | memcpy (p, | 210 | memcpy (p, |
211 | session->security_parameters.extensions.server_names[0]. | 211 | session->security_parameters.extensions. |
212 | name, len); | 212 | server_names[0].name, len); |
213 | p += len; | 213 | p += len; |
214 | break; | 214 | break; |
215 | default: | 215 | 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, | |||
1188 | for (i = j = 0; i < SUPPORTED_COMPRESSION_METHODS; i++) | 1188 | for (i = j = 0; i < SUPPORTED_COMPRESSION_METHODS; i++) |
1189 | { | 1189 | { |
1190 | int tmp = | 1190 | int tmp = |
1191 | MHD_gtls_compression_get_num (session->internals. | 1191 | MHD_gtls_compression_get_num (session->internals.priorities. |
1192 | priorities.compression.priority[i]); | 1192 | compression.priority[i]); |
1193 | 1193 | ||
1194 | /* remove private compression algorithms, if requested. | 1194 | /* remove private compression algorithms, if requested. |
1195 | */ | 1195 | */ |
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) | |||
166 | 166 | ||
167 | return | 167 | return |
168 | MHD_gtls_map_kx_get_cred (MHD_gtls_cipher_suite_get_kx_algo | 168 | MHD_gtls_map_kx_get_cred (MHD_gtls_cipher_suite_get_kx_algo |
169 | (&session-> | 169 | (&session->security_parameters. |
170 | security_parameters.current_cipher_suite), | 170 | current_cipher_suite), server); |
171 | server); | ||
172 | } | 171 | } |
173 | 172 | ||
174 | /* | 173 | /* |
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, | |||
734 | session->internals.record_send_buffer_prev_size += n - left; | 734 | session->internals.record_send_buffer_prev_size += n - left; |
735 | 735 | ||
736 | retval = | 736 | retval = |
737 | MHD__gnutls_buffer_insert (&session->internals. | 737 | MHD__gnutls_buffer_insert (&session-> |
738 | record_send_buffer, &ptr[n - left], | 738 | internals.record_send_buffer, |
739 | left); | 739 | &ptr[n - left], left); |
740 | if (retval < 0) | 740 | if (retval < 0) |
741 | { | 741 | { |
742 | MHD_gnutls_assert (); | 742 | MHD_gnutls_assert (); |
@@ -944,8 +944,8 @@ MHD_gtls_handshake_io_send_int (MHD_gtls_session_t session, | |||
944 | MHD_gnutls_assert (); | 944 | MHD_gnutls_assert (); |
945 | 945 | ||
946 | retval = | 946 | retval = |
947 | MHD__gnutls_buffer_insert (&session-> | 947 | MHD__gnutls_buffer_insert (&session->internals. |
948 | internals.handshake_send_buffer, | 948 | handshake_send_buffer, |
949 | &ptr[n - left], left); | 949 | &ptr[n - left], left); |
950 | if (retval < 0) | 950 | if (retval < 0) |
951 | { | 951 | { |
@@ -1047,9 +1047,8 @@ MHD_gtls_handshake_io_recv_int (MHD_gtls_session_t session, | |||
1047 | 1047 | ||
1048 | session->internals.handshake_recv_buffer.data | 1048 | session->internals.handshake_recv_buffer.data |
1049 | = | 1049 | = |
1050 | MHD_gtls_realloc_fast (session-> | 1050 | MHD_gtls_realloc_fast (session->internals. |
1051 | internals.handshake_recv_buffer.data, | 1051 | handshake_recv_buffer.data, dsize); |
1052 | dsize); | ||
1053 | if (session->internals.handshake_recv_buffer.data == NULL) | 1052 | if (session->internals.handshake_recv_buffer.data == NULL) |
1054 | { | 1053 | { |
1055 | MHD_gnutls_assert (); | 1054 | MHD_gnutls_assert (); |
@@ -1100,9 +1099,13 @@ MHD_gtls_handshake_buffer_put (MHD_gtls_session_t session, opaque * data, | |||
1100 | 1099 | ||
1101 | if ((session->internals.max_handshake_data_buffer_size > 0) && ((length | 1100 | if ((session->internals.max_handshake_data_buffer_size > 0) && ((length |
1102 | + | 1101 | + |
1103 | session->internals.handshake_hash_buffer.length) | 1102 | session-> |
1104 | > | 1103 | internals. |
1105 | session->internals.max_handshake_data_buffer_size)) | 1104 | handshake_hash_buffer. |
1105 | length) > | ||
1106 | session-> | ||
1107 | internals. | ||
1108 | max_handshake_data_buffer_size)) | ||
1106 | { | 1109 | { |
1107 | MHD_gnutls_assert (); | 1110 | MHD_gnutls_assert (); |
1108 | return GNUTLS_E_MEMORY_ERROR; | 1111 | 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, | |||
212 | uint8_t type = _type; | 212 | uint8_t type = _type; |
213 | uint8_t major, minor; | 213 | uint8_t major, minor; |
214 | int hash_size = | 214 | int hash_size = |
215 | MHD_gnutls_hash_get_algo_len (session-> | 215 | MHD_gnutls_hash_get_algo_len (session->security_parameters. |
216 | security_parameters.write_mac_algorithm); | 216 | write_mac_algorithm); |
217 | enum MHD_GNUTLS_Protocol ver; | 217 | enum MHD_GNUTLS_Protocol ver; |
218 | int blocksize = | 218 | int blocksize = |
219 | MHD_gtls_cipher_get_block_size (session-> | 219 | MHD_gtls_cipher_get_block_size (session->security_parameters. |
220 | security_parameters.write_bulk_cipher_algorithm); | 220 | write_bulk_cipher_algorithm); |
221 | cipher_type_t block_algo = | 221 | cipher_type_t block_algo = |
222 | MHD_gtls_cipher_is_block (session-> | 222 | MHD_gtls_cipher_is_block (session->security_parameters. |
223 | security_parameters.write_bulk_cipher_algorithm); | 223 | write_bulk_cipher_algorithm); |
224 | opaque *data_ptr; | 224 | opaque *data_ptr; |
225 | 225 | ||
226 | 226 | ||
@@ -247,9 +247,8 @@ MHD_gtls_compressed2ciphertext (MHD_gtls_session_t session, | |||
247 | if (td != GNUTLS_MAC_FAILED) | 247 | if (td != GNUTLS_MAC_FAILED) |
248 | { /* actually when the algorithm in not the NULL one */ | 248 | { /* actually when the algorithm in not the NULL one */ |
249 | MHD_gnutls_hash (td, | 249 | MHD_gnutls_hash (td, |
250 | UINT64DATA (session-> | 250 | UINT64DATA (session->connection_state. |
251 | connection_state.write_sequence_number), | 251 | write_sequence_number), 8); |
252 | 8); | ||
253 | 252 | ||
254 | MHD_gnutls_hash (td, &type, 1); | 253 | MHD_gnutls_hash (td, &type, 1); |
255 | if (ver >= MHD_GNUTLS_PROTOCOL_TLS1_0) | 254 | if (ver >= MHD_GNUTLS_PROTOCOL_TLS1_0) |
@@ -343,16 +342,16 @@ MHD_gtls_ciphertext2compressed (MHD_gtls_session_t session, | |||
343 | uint8_t major, minor; | 342 | uint8_t major, minor; |
344 | enum MHD_GNUTLS_Protocol ver; | 343 | enum MHD_GNUTLS_Protocol ver; |
345 | int hash_size = | 344 | int hash_size = |
346 | MHD_gnutls_hash_get_algo_len (session-> | 345 | MHD_gnutls_hash_get_algo_len (session->security_parameters. |
347 | security_parameters.read_mac_algorithm); | 346 | read_mac_algorithm); |
348 | 347 | ||
349 | ver = MHD__gnutls_protocol_get_version (session); | 348 | ver = MHD__gnutls_protocol_get_version (session); |
350 | minor = MHD_gtls_version_get_minor (ver); | 349 | minor = MHD_gtls_version_get_minor (ver); |
351 | major = MHD_gtls_version_get_major (ver); | 350 | major = MHD_gtls_version_get_major (ver); |
352 | 351 | ||
353 | blocksize = | 352 | blocksize = |
354 | MHD_gtls_cipher_get_block_size (session-> | 353 | MHD_gtls_cipher_get_block_size (session->security_parameters. |
355 | security_parameters.read_bulk_cipher_algorithm); | 354 | read_bulk_cipher_algorithm); |
356 | 355 | ||
357 | /* initialize MAC | 356 | /* initialize MAC |
358 | */ | 357 | */ |
@@ -376,9 +375,9 @@ MHD_gtls_ciphertext2compressed (MHD_gtls_session_t session, | |||
376 | { | 375 | { |
377 | case CIPHER_STREAM: | 376 | case CIPHER_STREAM: |
378 | if ((ret = | 377 | if ((ret = |
379 | MHD_gtls_cipher_decrypt (session-> | 378 | MHD_gtls_cipher_decrypt (session->connection_state. |
380 | connection_state.read_cipher_state, | 379 | read_cipher_state, ciphertext.data, |
381 | ciphertext.data, ciphertext.size)) < 0) | 380 | ciphertext.size)) < 0) |
382 | { | 381 | { |
383 | MHD_gnutls_assert (); | 382 | MHD_gnutls_assert (); |
384 | return ret; | 383 | return ret; |
@@ -395,9 +394,9 @@ MHD_gtls_ciphertext2compressed (MHD_gtls_session_t session, | |||
395 | } | 394 | } |
396 | 395 | ||
397 | if ((ret = | 396 | if ((ret = |
398 | MHD_gtls_cipher_decrypt (session-> | 397 | MHD_gtls_cipher_decrypt (session->connection_state. |
399 | connection_state.read_cipher_state, | 398 | read_cipher_state, ciphertext.data, |
400 | ciphertext.data, ciphertext.size)) < 0) | 399 | ciphertext.size)) < 0) |
401 | { | 400 | { |
402 | MHD_gnutls_assert (); | 401 | MHD_gnutls_assert (); |
403 | return ret; | 402 | return ret; |
@@ -455,8 +454,8 @@ MHD_gtls_ciphertext2compressed (MHD_gtls_session_t session, | |||
455 | if (td != GNUTLS_MAC_FAILED) | 454 | if (td != GNUTLS_MAC_FAILED) |
456 | { | 455 | { |
457 | MHD_gnutls_hash (td, | 456 | MHD_gnutls_hash (td, |
458 | UINT64DATA (session-> | 457 | UINT64DATA (session->connection_state. |
459 | connection_state.read_sequence_number), 8); | 458 | read_sequence_number), 8); |
460 | 459 | ||
461 | MHD_gnutls_hash (td, &type, 1); | 460 | MHD_gnutls_hash (td, &type, 1); |
462 | if (ver >= MHD_GNUTLS_PROTOCOL_TLS1_0) | 461 | 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, | |||
105 | { /* TLS 1.0 */ | 105 | { /* TLS 1.0 */ |
106 | ret = | 106 | ret = |
107 | MHD_gtls_PRF (session, | 107 | MHD_gtls_PRF (session, |
108 | (const unsigned char *) session->security_parameters. | 108 | (const unsigned char *) session-> |
109 | master_secret, TLS_MASTER_SIZE, keyexp, keyexp_length, | 109 | security_parameters.master_secret, TLS_MASTER_SIZE, |
110 | rnd, 2 * TLS_RANDOM_SIZE, block_size, key_block); | 110 | keyexp, keyexp_length, rnd, 2 * TLS_RANDOM_SIZE, |
111 | block_size, key_block); | ||
111 | } | 112 | } |
112 | 113 | ||
113 | if (ret < 0) | 114 | if (ret < 0) |
@@ -506,35 +507,35 @@ MHD_gtls_read_connection_state_init (MHD_gtls_session_t session) | |||
506 | { | 507 | { |
507 | rc = MHD_gtls_set_read_cipher (session, | 508 | rc = MHD_gtls_set_read_cipher (session, |
508 | MHD_gtls_cipher_suite_get_cipher_algo | 509 | MHD_gtls_cipher_suite_get_cipher_algo |
509 | (&session-> | 510 | (&session->security_parameters. |
510 | security_parameters.current_cipher_suite)); | 511 | current_cipher_suite)); |
511 | if (rc < 0) | 512 | if (rc < 0) |
512 | return rc; | 513 | return rc; |
513 | rc = MHD_gtls_set_read_mac (session, | 514 | rc = MHD_gtls_set_read_mac (session, |
514 | MHD_gtls_cipher_suite_get_mac_algo | 515 | MHD_gtls_cipher_suite_get_mac_algo |
515 | (&session-> | 516 | (&session->security_parameters. |
516 | security_parameters.current_cipher_suite)); | 517 | current_cipher_suite)); |
517 | if (rc < 0) | 518 | if (rc < 0) |
518 | return rc; | 519 | return rc; |
519 | 520 | ||
520 | rc = MHD_gtls_set_kx (session, | 521 | rc = MHD_gtls_set_kx (session, |
521 | MHD_gtls_cipher_suite_get_kx_algo | 522 | MHD_gtls_cipher_suite_get_kx_algo |
522 | (&session-> | 523 | (&session->security_parameters. |
523 | security_parameters.current_cipher_suite)); | 524 | current_cipher_suite)); |
524 | if (rc < 0) | 525 | if (rc < 0) |
525 | return rc; | 526 | return rc; |
526 | 527 | ||
527 | rc = MHD_gtls_set_read_compression (session, | 528 | rc = MHD_gtls_set_read_compression (session, |
528 | session-> | 529 | session->internals. |
529 | internals.compression_method); | 530 | compression_method); |
530 | if (rc < 0) | 531 | if (rc < 0) |
531 | return rc; | 532 | return rc; |
532 | } | 533 | } |
533 | else | 534 | else |
534 | { /* RESUME_TRUE */ | 535 | { /* RESUME_TRUE */ |
535 | MHD__gnutls_cpy_read_security_parameters (&session->security_parameters, | 536 | MHD__gnutls_cpy_read_security_parameters (&session->security_parameters, |
536 | &session-> | 537 | &session->internals. |
537 | internals.resumed_security_parameters); | 538 | resumed_security_parameters); |
538 | } | 539 | } |
539 | 540 | ||
540 | 541 | ||
@@ -545,8 +546,8 @@ MHD_gtls_read_connection_state_init (MHD_gtls_session_t session) | |||
545 | MHD__gnutls_handshake_log ("HSK[%x]: Cipher Suite: %s\n", | 546 | MHD__gnutls_handshake_log ("HSK[%x]: Cipher Suite: %s\n", |
546 | session, | 547 | session, |
547 | MHD_gtls_cipher_suite_get_name | 548 | MHD_gtls_cipher_suite_get_name |
548 | (&session-> | 549 | (&session->security_parameters. |
549 | security_parameters.current_cipher_suite)); | 550 | current_cipher_suite)); |
550 | 551 | ||
551 | if (MHD_gtls_compression_is_ok | 552 | if (MHD_gtls_compression_is_ok |
552 | (session->security_parameters.read_compression_algorithm) != 0) | 553 | (session->security_parameters.read_compression_algorithm) != 0) |
@@ -571,8 +572,8 @@ MHD_gtls_read_connection_state_init (MHD_gtls_session_t session) | |||
571 | MHD_gnutls_cipher_deinit (session->connection_state.read_cipher_state); | 572 | MHD_gnutls_cipher_deinit (session->connection_state.read_cipher_state); |
572 | 573 | ||
573 | mac_size = | 574 | mac_size = |
574 | MHD_gnutls_hash_get_algo_len (session-> | 575 | MHD_gnutls_hash_get_algo_len (session->security_parameters. |
575 | security_parameters.read_mac_algorithm); | 576 | read_mac_algorithm); |
576 | 577 | ||
577 | MHD__gnutls_handshake_log | 578 | MHD__gnutls_handshake_log |
578 | ("HSK[%x]: Initializing internal [read] cipher sessions\n", session); | 579 | ("HSK[%x]: Initializing internal [read] cipher sessions\n", session); |
@@ -583,8 +584,8 @@ MHD_gtls_read_connection_state_init (MHD_gtls_session_t session) | |||
583 | /* initialize cipher session | 584 | /* initialize cipher session |
584 | */ | 585 | */ |
585 | session->connection_state.read_cipher_state = | 586 | session->connection_state.read_cipher_state = |
586 | MHD_gtls_cipher_init (session-> | 587 | MHD_gtls_cipher_init (session->security_parameters. |
587 | security_parameters.read_bulk_cipher_algorithm, | 588 | read_bulk_cipher_algorithm, |
588 | &session->cipher_specs.client_write_key, | 589 | &session->cipher_specs.client_write_key, |
589 | &session->cipher_specs.client_write_IV); | 590 | &session->cipher_specs.client_write_IV); |
590 | if (session->connection_state.read_cipher_state == GNUTLS_CIPHER_FAILED | 591 | 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) | |||
615 | #if MHD_DEBUG_TLS | 616 | #if MHD_DEBUG_TLS |
616 | case GNUTLS_CLIENT: | 617 | case GNUTLS_CLIENT: |
617 | session->connection_state.read_cipher_state = | 618 | session->connection_state.read_cipher_state = |
618 | MHD_gtls_cipher_init (session-> | 619 | MHD_gtls_cipher_init (session->security_parameters. |
619 | security_parameters.read_bulk_cipher_algorithm, | 620 | read_bulk_cipher_algorithm, |
620 | &session->cipher_specs.server_write_key, | 621 | &session->cipher_specs.server_write_key, |
621 | &session->cipher_specs.server_write_IV); | 622 | &session->cipher_specs.server_write_IV); |
622 | 623 | ||
@@ -674,27 +675,27 @@ MHD_gtls_write_connection_state_init (MHD_gtls_session_t session) | |||
674 | { | 675 | { |
675 | rc = MHD_gtls_set_write_cipher (session, | 676 | rc = MHD_gtls_set_write_cipher (session, |
676 | MHD_gtls_cipher_suite_get_cipher_algo | 677 | MHD_gtls_cipher_suite_get_cipher_algo |
677 | (&session-> | 678 | (&session->security_parameters. |
678 | security_parameters.current_cipher_suite)); | 679 | current_cipher_suite)); |
679 | if (rc < 0) | 680 | if (rc < 0) |
680 | return rc; | 681 | return rc; |
681 | rc = MHD_gtls_set_write_mac (session, | 682 | rc = MHD_gtls_set_write_mac (session, |
682 | MHD_gtls_cipher_suite_get_mac_algo | 683 | MHD_gtls_cipher_suite_get_mac_algo |
683 | (&session-> | 684 | (&session->security_parameters. |
684 | security_parameters.current_cipher_suite)); | 685 | current_cipher_suite)); |
685 | if (rc < 0) | 686 | if (rc < 0) |
686 | return rc; | 687 | return rc; |
687 | 688 | ||
688 | rc = MHD_gtls_set_kx (session, | 689 | rc = MHD_gtls_set_kx (session, |
689 | MHD_gtls_cipher_suite_get_kx_algo | 690 | MHD_gtls_cipher_suite_get_kx_algo |
690 | (&session-> | 691 | (&session->security_parameters. |
691 | security_parameters.current_cipher_suite)); | 692 | current_cipher_suite)); |
692 | if (rc < 0) | 693 | if (rc < 0) |
693 | return rc; | 694 | return rc; |
694 | 695 | ||
695 | rc = MHD_gtls_set_write_compression (session, | 696 | rc = MHD_gtls_set_write_compression (session, |
696 | session-> | 697 | session->internals. |
697 | internals.compression_method); | 698 | compression_method); |
698 | if (rc < 0) | 699 | if (rc < 0) |
699 | return rc; | 700 | return rc; |
700 | } | 701 | } |
@@ -711,8 +712,8 @@ MHD_gtls_write_connection_state_init (MHD_gtls_session_t session) | |||
711 | 712 | ||
712 | MHD__gnutls_handshake_log ("HSK[%x]: Cipher Suite: %s\n", session, | 713 | MHD__gnutls_handshake_log ("HSK[%x]: Cipher Suite: %s\n", session, |
713 | MHD_gtls_cipher_suite_get_name | 714 | MHD_gtls_cipher_suite_get_name |
714 | (&session-> | 715 | (&session->security_parameters. |
715 | security_parameters.current_cipher_suite)); | 716 | current_cipher_suite)); |
716 | 717 | ||
717 | if (MHD_gtls_compression_is_ok | 718 | if (MHD_gtls_compression_is_ok |
718 | (session->security_parameters.write_compression_algorithm) != 0) | 719 | (session->security_parameters.write_compression_algorithm) != 0) |
@@ -739,8 +740,8 @@ MHD_gtls_write_connection_state_init (MHD_gtls_session_t session) | |||
739 | MHD_gnutls_cipher_deinit (session->connection_state.write_cipher_state); | 740 | MHD_gnutls_cipher_deinit (session->connection_state.write_cipher_state); |
740 | 741 | ||
741 | mac_size = | 742 | mac_size = |
742 | MHD_gnutls_hash_get_algo_len (session-> | 743 | MHD_gnutls_hash_get_algo_len (session->security_parameters. |
743 | security_parameters.write_mac_algorithm); | 744 | write_mac_algorithm); |
744 | 745 | ||
745 | MHD__gnutls_handshake_log | 746 | MHD__gnutls_handshake_log |
746 | ("HSK[%x]: Initializing internal [write] cipher sessions\n", session); | 747 | ("HSK[%x]: Initializing internal [write] cipher sessions\n", session); |
@@ -751,8 +752,8 @@ MHD_gtls_write_connection_state_init (MHD_gtls_session_t session) | |||
751 | /* initialize cipher session | 752 | /* initialize cipher session |
752 | */ | 753 | */ |
753 | session->connection_state.write_cipher_state = | 754 | session->connection_state.write_cipher_state = |
754 | MHD_gtls_cipher_init (session-> | 755 | MHD_gtls_cipher_init (session->security_parameters. |
755 | security_parameters.write_bulk_cipher_algorithm, | 756 | write_bulk_cipher_algorithm, |
756 | &session->cipher_specs.server_write_key, | 757 | &session->cipher_specs.server_write_key, |
757 | &session->cipher_specs.server_write_IV); | 758 | &session->cipher_specs.server_write_IV); |
758 | 759 | ||
@@ -787,8 +788,8 @@ MHD_gtls_write_connection_state_init (MHD_gtls_session_t session) | |||
787 | #if MHD_DEBUG_TLS | 788 | #if MHD_DEBUG_TLS |
788 | case GNUTLS_CLIENT: | 789 | case GNUTLS_CLIENT: |
789 | session->connection_state.write_cipher_state = | 790 | session->connection_state.write_cipher_state = |
790 | MHD_gtls_cipher_init (session-> | 791 | MHD_gtls_cipher_init (session->security_parameters. |
791 | security_parameters.write_bulk_cipher_algorithm, | 792 | write_bulk_cipher_algorithm, |
792 | &session->cipher_specs.client_write_key, | 793 | &session->cipher_specs.client_write_key, |
793 | &session->cipher_specs.client_write_IV); | 794 | &session->cipher_specs.client_write_IV); |
794 | 795 | ||
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) | |||
204 | { | 204 | { |
205 | if (session->internals.extensions_sent_size < MAX_EXT_TYPES) | 205 | if (session->internals.extensions_sent_size < MAX_EXT_TYPES) |
206 | { | 206 | { |
207 | session->internals.extensions_sent[session-> | 207 | session->internals.extensions_sent[session->internals. |
208 | internals.extensions_sent_size] = | 208 | extensions_sent_size] = type; |
209 | type; | ||
210 | session->internals.extensions_sent_size++; | 209 | session->internals.extensions_sent_size++; |
211 | } | 210 | } |
212 | else | 211 | 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) | |||
171 | MHD_gnutls_hash (td_sha, mesg, siz); | 171 | MHD_gnutls_hash (td_sha, mesg, siz); |
172 | 172 | ||
173 | MHD_gnutls_mac_deinit_ssl3_handshake (td_md5, ret, | 173 | MHD_gnutls_mac_deinit_ssl3_handshake (td_md5, ret, |
174 | session-> | 174 | session->security_parameters. |
175 | security_parameters.master_secret, | 175 | master_secret, TLS_MASTER_SIZE); |
176 | TLS_MASTER_SIZE); | ||
177 | MHD_gnutls_mac_deinit_ssl3_handshake (td_sha, &ret[16], | 176 | MHD_gnutls_mac_deinit_ssl3_handshake (td_sha, &ret[16], |
178 | session-> | 177 | session->security_parameters. |
179 | security_parameters.master_secret, | 178 | master_secret, TLS_MASTER_SIZE); |
180 | TLS_MASTER_SIZE); | ||
181 | 179 | ||
182 | return 0; | 180 | return 0; |
183 | } | 181 | } |
@@ -359,9 +357,9 @@ MHD__gnutls_read_client_hello (MHD_gtls_session_t session, opaque * data, | |||
359 | pos += session_id_len; | 357 | pos += session_id_len; |
360 | 358 | ||
361 | MHD_gtls_generate_session_id (session->security_parameters.session_id, | 359 | MHD_gtls_generate_session_id (session->security_parameters.session_id, |
362 | &session-> | 360 | &session->security_parameters. |
363 | security_parameters.session_id_size); | 361 | session_id_size); |
364 | 362 | ||
365 | session->internals.resumed = RESUME_FALSE; | 363 | session->internals.resumed = RESUME_FALSE; |
366 | /* Remember ciphersuites for later | 364 | /* Remember ciphersuites for later |
367 | */ | 365 | */ |
@@ -708,9 +706,9 @@ finish: | |||
708 | */ | 706 | */ |
709 | if (MHD_gtls_get_kx_cred | 707 | if (MHD_gtls_get_kx_cred |
710 | (session, | 708 | (session, |
711 | MHD_gtls_cipher_suite_get_kx_algo (&session-> | 709 | MHD_gtls_cipher_suite_get_kx_algo (&session->security_parameters. |
712 | security_parameters.current_cipher_suite), | 710 | current_cipher_suite), &err) == NULL |
713 | &err) == NULL && err != 0) | 711 | && err != 0) |
714 | { | 712 | { |
715 | MHD_gnutls_assert (); | 713 | MHD_gnutls_assert (); |
716 | return GNUTLS_E_INSUFFICIENT_CREDENTIALS; | 714 | return GNUTLS_E_INSUFFICIENT_CREDENTIALS; |
@@ -723,8 +721,8 @@ finish: | |||
723 | */ | 721 | */ |
724 | session->internals.auth_struct = | 722 | session->internals.auth_struct = |
725 | MHD_gtls_kx_auth_struct (MHD_gtls_cipher_suite_get_kx_algo | 723 | MHD_gtls_kx_auth_struct (MHD_gtls_cipher_suite_get_kx_algo |
726 | (&session-> | 724 | (&session->security_parameters. |
727 | security_parameters.current_cipher_suite)); | 725 | current_cipher_suite)); |
728 | if (session->internals.auth_struct == NULL) | 726 | if (session->internals.auth_struct == NULL) |
729 | { | 727 | { |
730 | 728 | ||
@@ -931,8 +929,8 @@ MHD__gnutls_recv_handshake_header (MHD_gtls_session_t session, | |||
931 | if (session->internals.handshake_header_buffer.header_size == | 929 | if (session->internals.handshake_header_buffer.header_size == |
932 | handshake_header_size || (session->internals.v2_hello != 0 | 930 | handshake_header_size || (session->internals.v2_hello != 0 |
933 | && type == GNUTLS_HANDSHAKE_CLIENT_HELLO | 931 | && type == GNUTLS_HANDSHAKE_CLIENT_HELLO |
934 | && session->internals.handshake_header_buffer. | 932 | && session->internals. |
935 | packet_length > 0)) | 933 | handshake_header_buffer.packet_length > 0)) |
936 | { | 934 | { |
937 | 935 | ||
938 | *recv_type = session->internals.handshake_header_buffer.recv_type; | 936 | *recv_type = session->internals.handshake_header_buffer.recv_type; |
@@ -975,13 +973,11 @@ MHD__gnutls_recv_handshake_header (MHD_gtls_session_t session, | |||
975 | MHD_gtls_handshake_io_recv_int (session, GNUTLS_HANDSHAKE, | 973 | MHD_gtls_handshake_io_recv_int (session, GNUTLS_HANDSHAKE, |
976 | type, | 974 | type, |
977 | &dataptr | 975 | &dataptr |
978 | [session-> | 976 | [session->internals. |
979 | internals.handshake_header_buffer. | 977 | handshake_header_buffer.header_size], |
980 | header_size], | ||
981 | HANDSHAKE_HEADER_SIZE - | 978 | HANDSHAKE_HEADER_SIZE - |
982 | session-> | 979 | session->internals. |
983 | internals.handshake_header_buffer. | 980 | handshake_header_buffer.header_size); |
984 | header_size); | ||
985 | if (ret <= 0) | 981 | if (ret <= 0) |
986 | { | 982 | { |
987 | MHD_gnutls_assert (); | 983 | MHD_gnutls_assert (); |
@@ -1164,12 +1160,11 @@ MHD_gtls_recv_handshake (MHD_gtls_session_t session, uint8_t ** data, | |||
1164 | 1160 | ||
1165 | 1161 | ||
1166 | ret = MHD__gnutls_handshake_hash_add_recvd (session, recv_type, | 1162 | ret = MHD__gnutls_handshake_hash_add_recvd (session, recv_type, |
1167 | session-> | 1163 | session->internals. |
1168 | internals.handshake_header_buffer. | 1164 | handshake_header_buffer.header, |
1169 | header, | 1165 | session->internals. |
1170 | session-> | 1166 | handshake_header_buffer.header_size, |
1171 | internals.handshake_header_buffer. | 1167 | dataptr, length32); |
1172 | header_size, dataptr, length32); | ||
1173 | if (ret < 0) | 1168 | if (ret < 0) |
1174 | { | 1169 | { |
1175 | MHD_gnutls_assert (); | 1170 | MHD_gnutls_assert (); |
@@ -1263,8 +1258,8 @@ MHD__gnutls_client_set_ciphersuite (MHD_gtls_session_t session, | |||
1263 | 1258 | ||
1264 | MHD__gnutls_handshake_log ("HSK[%x]: Selected cipher suite: %s\n", session, | 1259 | MHD__gnutls_handshake_log ("HSK[%x]: Selected cipher suite: %s\n", session, |
1265 | MHD_gtls_cipher_suite_get_name | 1260 | MHD_gtls_cipher_suite_get_name |
1266 | (&session-> | 1261 | (&session->security_parameters. |
1267 | security_parameters.current_cipher_suite)); | 1262 | current_cipher_suite)); |
1268 | 1263 | ||
1269 | 1264 | ||
1270 | /* check if the credentials (username, public key etc.) are ok. | 1265 | /* check if the credentials (username, public key etc.) are ok. |
@@ -1287,8 +1282,8 @@ MHD__gnutls_client_set_ciphersuite (MHD_gtls_session_t session, | |||
1287 | */ | 1282 | */ |
1288 | session->internals.auth_struct = | 1283 | session->internals.auth_struct = |
1289 | MHD_gtls_kx_auth_struct (MHD_gtls_cipher_suite_get_kx_algo | 1284 | MHD_gtls_kx_auth_struct (MHD_gtls_cipher_suite_get_kx_algo |
1290 | (&session-> | 1285 | (&session->security_parameters. |
1291 | security_parameters.current_cipher_suite)); | 1286 | current_cipher_suite)); |
1292 | 1287 | ||
1293 | if (session->internals.auth_struct == NULL) | 1288 | if (session->internals.auth_struct == NULL) |
1294 | { | 1289 | { |
@@ -1862,8 +1857,8 @@ MHD__gnutls_send_server_hello (MHD_gtls_session_t session, int again) | |||
1862 | pos += 2; | 1857 | pos += 2; |
1863 | 1858 | ||
1864 | comp = | 1859 | comp = |
1865 | (uint8_t) MHD_gtls_compression_get_num (session->internals. | 1860 | (uint8_t) MHD_gtls_compression_get_num (session-> |
1866 | compression_method); | 1861 | internals.compression_method); |
1867 | data[pos++] = comp; | 1862 | data[pos++] = comp; |
1868 | 1863 | ||
1869 | 1864 | ||
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) | |||
65 | MHD_gtls_bin2hex (PREMASTER.data, PREMASTER.size, buf, | 65 | MHD_gtls_bin2hex (PREMASTER.data, PREMASTER.size, buf, |
66 | sizeof (buf))); | 66 | sizeof (buf))); |
67 | MHD__gnutls_hard_log ("INT: CLIENT RANDOM[%d]: %s\n", 32, | 67 | MHD__gnutls_hard_log ("INT: CLIENT RANDOM[%d]: %s\n", 32, |
68 | MHD_gtls_bin2hex (session-> | 68 | MHD_gtls_bin2hex (session->security_parameters. |
69 | security_parameters.client_random, | 69 | client_random, 32, buf, |
70 | 32, buf, sizeof (buf))); | 70 | sizeof (buf))); |
71 | MHD__gnutls_hard_log ("INT: SERVER RANDOM[%d]: %s\n", 32, | 71 | MHD__gnutls_hard_log ("INT: SERVER RANDOM[%d]: %s\n", 32, |
72 | MHD_gtls_bin2hex (session-> | 72 | MHD_gtls_bin2hex (session->security_parameters. |
73 | security_parameters.server_random, | 73 | server_random, 32, buf, |
74 | 32, buf, sizeof (buf))); | 74 | sizeof (buf))); |
75 | 75 | ||
76 | if (MHD__gnutls_protocol_get_version (session) == MHD_GNUTLS_PROTOCOL_SSL3) | 76 | if (MHD__gnutls_protocol_get_version (session) == MHD_GNUTLS_PROTOCOL_SSL3) |
77 | { | 77 | { |
@@ -86,8 +86,8 @@ generate_normal_master (MHD_gtls_session_t session, int keep_premaster) | |||
86 | MHD_gnutls_ssl3_generate_random (PREMASTER.data, PREMASTER.size, | 86 | MHD_gnutls_ssl3_generate_random (PREMASTER.data, PREMASTER.size, |
87 | rnd, 2 * TLS_RANDOM_SIZE, | 87 | rnd, 2 * TLS_RANDOM_SIZE, |
88 | TLS_MASTER_SIZE, | 88 | TLS_MASTER_SIZE, |
89 | session-> | 89 | session->security_parameters. |
90 | security_parameters.master_secret); | 90 | master_secret); |
91 | 91 | ||
92 | } | 92 | } |
93 | else | 93 | else |
@@ -117,9 +117,8 @@ generate_normal_master (MHD_gtls_session_t session, int keep_premaster) | |||
117 | return ret; | 117 | return ret; |
118 | 118 | ||
119 | MHD__gnutls_hard_log ("INT: MASTER SECRET: %s\n", | 119 | MHD__gnutls_hard_log ("INT: MASTER SECRET: %s\n", |
120 | MHD_gtls_bin2hex (session-> | 120 | MHD_gtls_bin2hex (session->security_parameters. |
121 | security_parameters.master_secret, | 121 | master_secret, TLS_MASTER_SIZE, buf, |
122 | TLS_MASTER_SIZE, buf, | ||
123 | sizeof (buf))); | 122 | sizeof (buf))); |
124 | 123 | ||
125 | return ret; | 124 | return ret; |
@@ -186,8 +185,8 @@ MHD_gtls_send_server_certificate_request (MHD_gtls_session_t session, | |||
186 | int data_size = 0; | 185 | int data_size = 0; |
187 | int ret = 0; | 186 | int ret = 0; |
188 | 187 | ||
189 | if (session->internals. | 188 | if (session->internals.auth_struct-> |
190 | auth_struct->MHD_gtls_gen_server_certificate_request == NULL) | 189 | MHD_gtls_gen_server_certificate_request == NULL) |
191 | return 0; | 190 | return 0; |
192 | 191 | ||
193 | if (session->internals.send_cert_req <= 0) | 192 | if (session->internals.send_cert_req <= 0) |
@@ -199,8 +198,8 @@ MHD_gtls_send_server_certificate_request (MHD_gtls_session_t session, | |||
199 | if (again == 0) | 198 | if (again == 0) |
200 | { | 199 | { |
201 | data_size = | 200 | data_size = |
202 | session->internals. | 201 | session->internals.auth_struct-> |
203 | auth_struct->MHD_gtls_gen_server_certificate_request (session, &data); | 202 | MHD_gtls_gen_server_certificate_request (session, &data); |
204 | 203 | ||
205 | if (data_size < 0) | 204 | if (data_size < 0) |
206 | { | 205 | { |
@@ -299,8 +298,8 @@ MHD_gtls_send_client_certificate_verify (MHD_gtls_session_t session, | |||
299 | if (again == 0) | 298 | if (again == 0) |
300 | { | 299 | { |
301 | data_size = | 300 | data_size = |
302 | session->internals. | 301 | session->internals.auth_struct-> |
303 | auth_struct->MHD_gtls_gen_client_cert_vrfy (session, &data); | 302 | MHD_gtls_gen_client_cert_vrfy (session, &data); |
304 | if (data_size < 0) | 303 | if (data_size < 0) |
305 | { | 304 | { |
306 | MHD_gnutls_assert (); | 305 | MHD_gnutls_assert (); |
@@ -372,8 +371,8 @@ MHD_gtls_recv_server_certificate_request (MHD_gtls_session_t session) | |||
372 | int datasize; | 371 | int datasize; |
373 | int ret = 0; | 372 | int ret = 0; |
374 | 373 | ||
375 | if (session->internals. | 374 | if (session->internals.auth_struct-> |
376 | auth_struct->MHD_gtls_process_server_certificate_request != NULL) | 375 | MHD_gtls_process_server_certificate_request != NULL) |
377 | { | 376 | { |
378 | 377 | ||
379 | ret = | 378 | ret = |
@@ -388,10 +387,8 @@ MHD_gtls_recv_server_certificate_request (MHD_gtls_session_t session) | |||
388 | return 0; /* ignored */ | 387 | return 0; /* ignored */ |
389 | 388 | ||
390 | ret = | 389 | ret = |
391 | session->internals. | 390 | session->internals.auth_struct-> |
392 | auth_struct->MHD_gtls_process_server_certificate_request (session, | 391 | MHD_gtls_process_server_certificate_request (session, data, datasize); |
393 | data, | ||
394 | datasize); | ||
395 | MHD_gnutls_free (data); | 392 | MHD_gnutls_free (data); |
396 | if (ret < 0) | 393 | if (ret < 0) |
397 | return ret; | 394 | return ret; |
@@ -462,8 +459,8 @@ MHD_gtls_send_client_certificate (MHD_gtls_session_t session, int again) | |||
462 | /* TLS 1.0 or SSL 3.0 with a valid certificate | 459 | /* TLS 1.0 or SSL 3.0 with a valid certificate |
463 | */ | 460 | */ |
464 | data_size = | 461 | data_size = |
465 | session->internals. | 462 | session->internals.auth_struct-> |
466 | auth_struct->MHD_gtls_gen_client_certificate (session, &data); | 463 | MHD_gtls_gen_client_certificate (session, &data); |
467 | 464 | ||
468 | if (data_size < 0) | 465 | if (data_size < 0) |
469 | { | 466 | { |
@@ -523,8 +520,8 @@ MHD_gtls_send_server_certificate (MHD_gtls_session_t session, int again) | |||
523 | if (again == 0) | 520 | if (again == 0) |
524 | { | 521 | { |
525 | data_size = | 522 | data_size = |
526 | session->internals. | 523 | session->internals.auth_struct-> |
527 | auth_struct->MHD_gtls_gen_server_certificate (session, &data); | 524 | MHD_gtls_gen_server_certificate (session, &data); |
528 | 525 | ||
529 | if (data_size < 0) | 526 | if (data_size < 0) |
530 | { | 527 | { |
@@ -620,9 +617,8 @@ MHD_gtls_recv_client_certificate (MHD_gtls_session_t session) | |||
620 | return 0; | 617 | return 0; |
621 | } | 618 | } |
622 | ret = | 619 | ret = |
623 | session->internals. | 620 | session->internals.auth_struct-> |
624 | auth_struct->MHD_gtls_process_client_certificate (session, data, | 621 | MHD_gtls_process_client_certificate (session, data, datasize); |
625 | datasize); | ||
626 | 622 | ||
627 | MHD_gnutls_free (data); | 623 | MHD_gnutls_free (data); |
628 | if (ret < 0 && ret != GNUTLS_E_NO_CERTIFICATE_FOUND) | 624 | if (ret < 0 && ret != GNUTLS_E_NO_CERTIFICATE_FOUND) |
@@ -666,9 +662,8 @@ MHD_gtls_recv_server_certificate (MHD_gtls_session_t session) | |||
666 | } | 662 | } |
667 | 663 | ||
668 | ret = | 664 | ret = |
669 | session->internals. | 665 | session->internals.auth_struct-> |
670 | auth_struct->MHD_gtls_process_server_certificate (session, data, | 666 | MHD_gtls_process_server_certificate (session, data, datasize); |
671 | datasize); | ||
672 | MHD_gnutls_free (data); | 667 | MHD_gnutls_free (data); |
673 | if (ret < 0) | 668 | if (ret < 0) |
674 | { | 669 | { |
@@ -719,9 +714,8 @@ MHD_gtls_recv_client_certificate_verify_message (MHD_gtls_session_t session) | |||
719 | } | 714 | } |
720 | 715 | ||
721 | ret = | 716 | ret = |
722 | session->internals. | 717 | session->internals.auth_struct-> |
723 | auth_struct->MHD_gtls_process_client_cert_vrfy (session, data, | 718 | MHD_gtls_process_client_cert_vrfy (session, data, datasize); |
724 | datasize); | ||
725 | MHD_gnutls_free (data); | 719 | MHD_gnutls_free (data); |
726 | if (ret < 0) | 720 | if (ret < 0) |
727 | return ret; | 721 | 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, | |||
634 | gcry_sexp_release (s_sig); | 634 | gcry_sexp_release (s_sig); |
635 | return 0; | 635 | return 0; |
636 | } | 636 | } |
637 | |||
638 | |||
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, | |||
293 | 293 | ||
294 | MHD__gnutls_record_log | 294 | MHD__gnutls_record_log |
295 | ("REC[%x]: Sending Packet[%d] %s(%d) with length: %d\n", session, | 295 | ("REC[%x]: Sending Packet[%d] %s(%d) with length: %d\n", session, |
296 | (int) MHD_gtls_uint64touint32 (&session-> | 296 | (int) MHD_gtls_uint64touint32 (&session->connection_state. |
297 | connection_state.write_sequence_number), | 297 | write_sequence_number), |
298 | MHD__gnutls_packet2str (type), type, sizeofdata); | 298 | MHD__gnutls_packet2str (type), type, sizeofdata); |
299 | 299 | ||
300 | if (sizeofdata > MAX_RECORD_SEND_SIZE) | 300 | if (sizeofdata > MAX_RECORD_SEND_SIZE) |
@@ -856,13 +856,13 @@ begin: | |||
856 | 856 | ||
857 | MHD__gnutls_record_log | 857 | MHD__gnutls_record_log |
858 | ("REC[%x]: Expected Packet[%d] %s(%d) with length: %d\n", session, | 858 | ("REC[%x]: Expected Packet[%d] %s(%d) with length: %d\n", session, |
859 | (int) MHD_gtls_uint64touint32 (&session-> | 859 | (int) MHD_gtls_uint64touint32 (&session->connection_state. |
860 | connection_state.read_sequence_number), | 860 | read_sequence_number), |
861 | MHD__gnutls_packet2str (type), type, sizeofdata); | 861 | MHD__gnutls_packet2str (type), type, sizeofdata); |
862 | MHD__gnutls_record_log | 862 | MHD__gnutls_record_log |
863 | ("REC[%x]: Received Packet[%d] %s(%d) with length: %d\n", session, | 863 | ("REC[%x]: Received Packet[%d] %s(%d) with length: %d\n", session, |
864 | (int) MHD_gtls_uint64touint32 (&session-> | 864 | (int) MHD_gtls_uint64touint32 (&session->connection_state. |
865 | connection_state.read_sequence_number), | 865 | read_sequence_number), |
866 | MHD__gnutls_packet2str (recv_type), recv_type, length); | 866 | MHD__gnutls_packet2str (recv_type), recv_type, length); |
867 | 867 | ||
868 | if (length > MAX_RECV_SIZE) | 868 | if (length > MAX_RECV_SIZE) |
@@ -938,8 +938,8 @@ begin: | |||
938 | 938 | ||
939 | MHD__gnutls_record_log | 939 | MHD__gnutls_record_log |
940 | ("REC[%x]: Decrypted Packet[%d] %s(%d) with length: %d\n", session, | 940 | ("REC[%x]: Decrypted Packet[%d] %s(%d) with length: %d\n", session, |
941 | (int) MHD_gtls_uint64touint32 (&session-> | 941 | (int) MHD_gtls_uint64touint32 (&session->connection_state. |
942 | connection_state.read_sequence_number), | 942 | read_sequence_number), |
943 | MHD__gnutls_packet2str (recv_type), recv_type, decrypted_length); | 943 | MHD__gnutls_packet2str (recv_type), recv_type, decrypted_length); |
944 | 944 | ||
945 | /* increase sequence number | 945 | /* 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, | |||
75 | } | 75 | } |
76 | 76 | ||
77 | MHD_gnutls_mac_deinit_ssl3_handshake (td_sha, &concat[16], | 77 | MHD_gnutls_mac_deinit_ssl3_handshake (td_sha, &concat[16], |
78 | session-> | 78 | session->security_parameters. |
79 | security_parameters.master_secret, | 79 | master_secret, TLS_MASTER_SIZE); |
80 | TLS_MASTER_SIZE); | ||
81 | } | 80 | } |
82 | else | 81 | else |
83 | MHD_gnutls_hash_deinit (td_sha, &concat[16]); | 82 | MHD_gnutls_hash_deinit (td_sha, &concat[16]); |
@@ -95,9 +94,8 @@ MHD_gtls_tls_sign_hdata (MHD_gtls_session_t session, | |||
95 | 94 | ||
96 | if (ver == MHD_GNUTLS_PROTOCOL_SSL3) | 95 | if (ver == MHD_GNUTLS_PROTOCOL_SSL3) |
97 | MHD_gnutls_mac_deinit_ssl3_handshake (td_md5, concat, | 96 | MHD_gnutls_mac_deinit_ssl3_handshake (td_md5, concat, |
98 | session-> | 97 | session->security_parameters. |
99 | security_parameters.master_secret, | 98 | master_secret, TLS_MASTER_SIZE); |
100 | TLS_MASTER_SIZE); | ||
101 | else | 99 | else |
102 | MHD_gnutls_hash_deinit (td_md5, concat); | 100 | MHD_gnutls_hash_deinit (td_md5, concat); |
103 | 101 | ||
@@ -267,8 +265,8 @@ MHD__gnutls_tls_sign (MHD_gtls_session_t session, | |||
267 | return GNUTLS_E_INSUFFICIENT_CREDENTIALS; | 265 | return GNUTLS_E_INSUFFICIENT_CREDENTIALS; |
268 | 266 | ||
269 | return (*session->internals.sign_func) (session, | 267 | return (*session->internals.sign_func) (session, |
270 | session-> | 268 | session->internals. |
271 | internals.sign_func_userdata, | 269 | sign_func_userdata, |
272 | cert->cert_type, &cert->raw, | 270 | cert->cert_type, &cert->raw, |
273 | hash_concat, signature); | 271 | hash_concat, signature); |
274 | } | 272 | } |
@@ -367,13 +365,11 @@ MHD_gtls_verify_sig_hdata (MHD_gtls_session_t session, | |||
367 | } | 365 | } |
368 | 366 | ||
369 | MHD_gnutls_mac_deinit_ssl3_handshake (td_md5, concat, | 367 | MHD_gnutls_mac_deinit_ssl3_handshake (td_md5, concat, |
370 | session-> | 368 | session->security_parameters. |
371 | security_parameters.master_secret, | 369 | master_secret, TLS_MASTER_SIZE); |
372 | TLS_MASTER_SIZE); | ||
373 | MHD_gnutls_mac_deinit_ssl3_handshake (td_sha, &concat[16], | 370 | MHD_gnutls_mac_deinit_ssl3_handshake (td_sha, &concat[16], |
374 | session-> | 371 | session->security_parameters. |
375 | security_parameters.master_secret, | 372 | master_secret, TLS_MASTER_SIZE); |
376 | TLS_MASTER_SIZE); | ||
377 | } | 373 | } |
378 | else | 374 | else |
379 | { | 375 | { |
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) | |||
771 | enum MHD_GNUTLS_CipherAlgorithm cipher; | 771 | enum MHD_GNUTLS_CipherAlgorithm cipher; |
772 | 772 | ||
773 | cipher = | 773 | cipher = |
774 | MHD_gtls_cipher_suite_get_cipher_algo (&session-> | 774 | MHD_gtls_cipher_suite_get_cipher_algo (&session->security_parameters. |
775 | security_parameters.current_cipher_suite); | 775 | current_cipher_suite); |
776 | 776 | ||
777 | if (MHD_gtls_cipher_get_export_flag (cipher) != 0) | 777 | if (MHD_gtls_cipher_get_export_flag (cipher) != 0) |
778 | return 1; | 778 | 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) | |||
113 | 1].params_size, &kid); | 113 | 1].params_size, &kid); |
114 | 114 | ||
115 | 115 | ||
116 | MHD__gnutls_x509_write_rsa_params (res->cert_list[res->ncerts - 1][0]. | 116 | MHD__gnutls_x509_write_rsa_params (res-> |
117 | params, | 117 | cert_list[res->ncerts - 1][0].params, |
118 | res->cert_list[res->ncerts - | 118 | res->cert_list[res->ncerts - |
119 | 1][0].params_size, &cid); | 119 | 1][0].params_size, &cid); |
120 | 120 | ||
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 @@ | |||
37 | HAYSTACK. */ | 37 | HAYSTACK. */ |
38 | void * | 38 | void * |
39 | memmem (const void *haystack_start, size_t haystack_len, | 39 | memmem (const void *haystack_start, size_t haystack_len, |
40 | const void *needle_start, size_t needle_len) | 40 | const void *needle_start, size_t needle_len) |
41 | { | 41 | { |
42 | /* Abstract memory is considered to be an array of 'unsigned char' values, | 42 | /* Abstract memory is considered to be an array of 'unsigned char' values, |
43 | not an array of 'char' values. See ISO C 99 section 6.2.6.1. */ | 43 | 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, | |||
62 | { | 62 | { |
63 | haystack = memchr (haystack, *needle, haystack_len); | 63 | haystack = memchr (haystack, *needle, haystack_len); |
64 | if (!haystack || __builtin_expect (needle_len == 1, 0)) | 64 | if (!haystack || __builtin_expect (needle_len == 1, 0)) |
65 | return (void *) haystack; | 65 | return (void *) haystack; |
66 | haystack_len -= haystack - (const unsigned char *) haystack_start; | 66 | haystack_len -= haystack - (const unsigned char *) haystack_start; |
67 | if (haystack_len < needle_len) | 67 | if (haystack_len < needle_len) |
68 | return NULL; | 68 | return NULL; |
69 | return two_way_short_needle (haystack, haystack_len, needle, needle_len); | 69 | return two_way_short_needle (haystack, haystack_len, needle, |
70 | needle_len); | ||
70 | } | 71 | } |
71 | else | 72 | else |
72 | return two_way_long_needle (haystack, haystack_len, needle, needle_len); | 73 | 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 @@ | |||
103 | periodicity. */ | 103 | periodicity. */ |
104 | static size_t | 104 | static size_t |
105 | critical_factorization (const unsigned char *needle, size_t needle_len, | 105 | critical_factorization (const unsigned char *needle, size_t needle_len, |
106 | size_t *period) | 106 | size_t * period) |
107 | { | 107 | { |
108 | /* Index of last byte of left half, or SIZE_MAX. */ | 108 | /* Index of last byte of left half, or SIZE_MAX. */ |
109 | size_t max_suffix, max_suffix_rev; | 109 | size_t max_suffix, max_suffix_rev; |
110 | size_t j; /* Index into NEEDLE for current candidate suffix. */ | 110 | size_t j; /* Index into NEEDLE for current candidate suffix. */ |
111 | size_t k; /* Offset into current period. */ | 111 | size_t k; /* Offset into current period. */ |
112 | size_t p; /* Intermediate period. */ | 112 | size_t p; /* Intermediate period. */ |
113 | unsigned char a, b; /* Current comparison bytes. */ | 113 | unsigned char a, b; /* Current comparison bytes. */ |
114 | 114 | ||
115 | /* Invariants: | 115 | /* Invariants: |
116 | 0 <= j < NEEDLE_LEN - 1 | 116 | 0 <= j < NEEDLE_LEN - 1 |
@@ -119,7 +119,7 @@ critical_factorization (const unsigned char *needle, size_t needle_len, | |||
119 | 1 <= p <= global period of NEEDLE | 119 | 1 <= p <= global period of NEEDLE |
120 | p == global period of the substring NEEDLE[max_suffix{,_rev}+1...j] | 120 | p == global period of the substring NEEDLE[max_suffix{,_rev}+1...j] |
121 | 1 <= k <= p | 121 | 1 <= k <= p |
122 | */ | 122 | */ |
123 | 123 | ||
124 | /* Perform lexicographic search. */ | 124 | /* Perform lexicographic search. */ |
125 | max_suffix = SIZE_MAX; | 125 | max_suffix = SIZE_MAX; |
@@ -130,29 +130,29 @@ critical_factorization (const unsigned char *needle, size_t needle_len, | |||
130 | a = CANON_ELEMENT (needle[j + k]); | 130 | a = CANON_ELEMENT (needle[j + k]); |
131 | b = CANON_ELEMENT (needle[max_suffix + k]); | 131 | b = CANON_ELEMENT (needle[max_suffix + k]); |
132 | if (a < b) | 132 | if (a < b) |
133 | { | 133 | { |
134 | /* Suffix is smaller, period is entire prefix so far. */ | 134 | /* Suffix is smaller, period is entire prefix so far. */ |
135 | j += k; | 135 | j += k; |
136 | k = 1; | 136 | k = 1; |
137 | p = j - max_suffix; | 137 | p = j - max_suffix; |
138 | } | 138 | } |
139 | else if (a == b) | 139 | else if (a == b) |
140 | { | 140 | { |
141 | /* Advance through repetition of the current period. */ | 141 | /* Advance through repetition of the current period. */ |
142 | if (k != p) | 142 | if (k != p) |
143 | ++k; | 143 | ++k; |
144 | else | 144 | else |
145 | { | 145 | { |
146 | j += p; | 146 | j += p; |
147 | k = 1; | 147 | k = 1; |
148 | } | 148 | } |
149 | } | 149 | } |
150 | else /* b < a */ | 150 | else /* b < a */ |
151 | { | 151 | { |
152 | /* Suffix is larger, start over from current location. */ | 152 | /* Suffix is larger, start over from current location. */ |
153 | max_suffix = j++; | 153 | max_suffix = j++; |
154 | k = p = 1; | 154 | k = p = 1; |
155 | } | 155 | } |
156 | } | 156 | } |
157 | *period = p; | 157 | *period = p; |
158 | 158 | ||
@@ -165,29 +165,29 @@ critical_factorization (const unsigned char *needle, size_t needle_len, | |||
165 | a = CANON_ELEMENT (needle[j + k]); | 165 | a = CANON_ELEMENT (needle[j + k]); |
166 | b = CANON_ELEMENT (needle[max_suffix_rev + k]); | 166 | b = CANON_ELEMENT (needle[max_suffix_rev + k]); |
167 | if (b < a) | 167 | if (b < a) |
168 | { | 168 | { |
169 | /* Suffix is smaller, period is entire prefix so far. */ | 169 | /* Suffix is smaller, period is entire prefix so far. */ |
170 | j += k; | 170 | j += k; |
171 | k = 1; | 171 | k = 1; |
172 | p = j - max_suffix_rev; | 172 | p = j - max_suffix_rev; |
173 | } | 173 | } |
174 | else if (a == b) | 174 | else if (a == b) |
175 | { | 175 | { |
176 | /* Advance through repetition of the current period. */ | 176 | /* Advance through repetition of the current period. */ |
177 | if (k != p) | 177 | if (k != p) |
178 | ++k; | 178 | ++k; |
179 | else | 179 | else |
180 | { | 180 | { |
181 | j += p; | 181 | j += p; |
182 | k = 1; | 182 | k = 1; |
183 | } | 183 | } |
184 | } | 184 | } |
185 | else /* a < b */ | 185 | else /* a < b */ |
186 | { | 186 | { |
187 | /* Suffix is larger, start over from current location. */ | 187 | /* Suffix is larger, start over from current location. */ |
188 | max_suffix_rev = j++; | 188 | max_suffix_rev = j++; |
189 | k = p = 1; | 189 | k = p = 1; |
190 | } | 190 | } |
191 | } | 191 | } |
192 | 192 | ||
193 | /* Choose the longer suffix. Return the first byte of the right | 193 | /* 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, | |||
210 | HAYSTACK_LEN - NEEDLE_LEN comparisons occur in searching. */ | 210 | HAYSTACK_LEN - NEEDLE_LEN comparisons occur in searching. */ |
211 | static RETURN_TYPE | 211 | static RETURN_TYPE |
212 | two_way_short_needle (const unsigned char *haystack, size_t haystack_len, | 212 | two_way_short_needle (const unsigned char *haystack, size_t haystack_len, |
213 | const unsigned char *needle, size_t needle_len) | 213 | const unsigned char *needle, size_t needle_len) |
214 | { | 214 | { |
215 | size_t i; /* Index into current byte of NEEDLE. */ | 215 | size_t i; /* Index into current byte of NEEDLE. */ |
216 | size_t j; /* Index into current window of HAYSTACK. */ | 216 | size_t j; /* Index into current window of HAYSTACK. */ |
217 | size_t period; /* The period of the right half of needle. */ | 217 | size_t period; /* The period of the right half of needle. */ |
218 | size_t suffix; /* The index of the right half of needle. */ | 218 | size_t suffix; /* The index of the right half of needle. */ |
219 | 219 | ||
220 | /* Factor the needle into two halves, such that the left half is | 220 | /* Factor the needle into two halves, such that the left half is |
221 | smaller than the global period, and the right half is | 221 | 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, | |||
227 | if (CMP_FUNC (needle, needle + period, suffix) == 0) | 227 | if (CMP_FUNC (needle, needle + period, suffix) == 0) |
228 | { | 228 | { |
229 | /* Entire needle is periodic; a mismatch can only advance by the | 229 | /* Entire needle is periodic; a mismatch can only advance by the |
230 | period, so use memory to avoid rescanning known occurrences | 230 | period, so use memory to avoid rescanning known occurrences |
231 | of the period. */ | 231 | of the period. */ |
232 | size_t memory = 0; | 232 | size_t memory = 0; |
233 | j = 0; | 233 | j = 0; |
234 | while (AVAILABLE (haystack, haystack_len, j, needle_len)) | 234 | while (AVAILABLE (haystack, haystack_len, j, needle_len)) |
235 | { | 235 | { |
236 | /* Scan for matches in right half. */ | 236 | /* Scan for matches in right half. */ |
237 | i = MAX (suffix, memory); | 237 | i = MAX (suffix, memory); |
238 | while (i < needle_len && (CANON_ELEMENT (needle[i]) | 238 | while (i < needle_len && (CANON_ELEMENT (needle[i]) |
239 | == CANON_ELEMENT (haystack[i + j]))) | 239 | == CANON_ELEMENT (haystack[i + j]))) |
240 | ++i; | 240 | ++i; |
241 | if (needle_len <= i) | 241 | if (needle_len <= i) |
242 | { | 242 | { |
243 | /* Scan for matches in left half. */ | 243 | /* Scan for matches in left half. */ |
244 | i = suffix - 1; | 244 | i = suffix - 1; |
245 | while (memory < i + 1 && (CANON_ELEMENT (needle[i]) | 245 | while (memory < i + 1 && (CANON_ELEMENT (needle[i]) |
246 | == CANON_ELEMENT (haystack[i + j]))) | 246 | == CANON_ELEMENT (haystack[i + j]))) |
247 | --i; | 247 | --i; |
248 | if (i + 1 < memory + 1) | 248 | if (i + 1 < memory + 1) |
249 | return (RETURN_TYPE) (haystack + j); | 249 | return (RETURN_TYPE) (haystack + j); |
250 | /* No match, so remember how many repetitions of period | 250 | /* No match, so remember how many repetitions of period |
251 | on the right half were scanned. */ | 251 | on the right half were scanned. */ |
252 | j += period; | 252 | j += period; |
253 | memory = needle_len - period; | 253 | memory = needle_len - period; |
254 | } | 254 | } |
255 | else | 255 | else |
256 | { | 256 | { |
257 | j += i - suffix + 1; | 257 | j += i - suffix + 1; |
258 | memory = 0; | 258 | memory = 0; |
259 | } | 259 | } |
260 | } | 260 | } |
261 | } | 261 | } |
262 | else | 262 | else |
263 | { | 263 | { |
264 | /* The two halves of needle are distinct; no extra memory is | 264 | /* The two halves of needle are distinct; no extra memory is |
265 | required, and any mismatch results in a maximal shift. */ | 265 | required, and any mismatch results in a maximal shift. */ |
266 | period = MAX (suffix, needle_len - suffix) + 1; | 266 | period = MAX (suffix, needle_len - suffix) + 1; |
267 | j = 0; | 267 | j = 0; |
268 | while (AVAILABLE (haystack, haystack_len, j, needle_len)) | 268 | while (AVAILABLE (haystack, haystack_len, j, needle_len)) |
269 | { | 269 | { |
270 | /* Scan for matches in right half. */ | 270 | /* Scan for matches in right half. */ |
271 | i = suffix; | 271 | i = suffix; |
272 | while (i < needle_len && (CANON_ELEMENT (needle[i]) | 272 | while (i < needle_len && (CANON_ELEMENT (needle[i]) |
273 | == CANON_ELEMENT (haystack[i + j]))) | 273 | == CANON_ELEMENT (haystack[i + j]))) |
274 | ++i; | 274 | ++i; |
275 | if (needle_len <= i) | 275 | if (needle_len <= i) |
276 | { | 276 | { |
277 | /* Scan for matches in left half. */ | 277 | /* Scan for matches in left half. */ |
278 | i = suffix - 1; | 278 | i = suffix - 1; |
279 | while (i != SIZE_MAX && (CANON_ELEMENT (needle[i]) | 279 | while (i != SIZE_MAX && (CANON_ELEMENT (needle[i]) |
280 | == CANON_ELEMENT (haystack[i + j]))) | 280 | == CANON_ELEMENT (haystack[i + j]))) |
281 | --i; | 281 | --i; |
282 | if (i == SIZE_MAX) | 282 | if (i == SIZE_MAX) |
283 | return (RETURN_TYPE) (haystack + j); | 283 | return (RETURN_TYPE) (haystack + j); |
284 | j += period; | 284 | j += period; |
285 | } | 285 | } |
286 | else | 286 | else |
287 | j += i - suffix + 1; | 287 | j += i - suffix + 1; |
288 | } | 288 | } |
289 | } | 289 | } |
290 | return NULL; | 290 | return NULL; |
291 | } | 291 | } |
@@ -304,13 +304,13 @@ two_way_short_needle (const unsigned char *haystack, size_t haystack_len, | |||
304 | sublinear performance is not possible. */ | 304 | sublinear performance is not possible. */ |
305 | static RETURN_TYPE | 305 | static RETURN_TYPE |
306 | two_way_long_needle (const unsigned char *haystack, size_t haystack_len, | 306 | two_way_long_needle (const unsigned char *haystack, size_t haystack_len, |
307 | const unsigned char *needle, size_t needle_len) | 307 | const unsigned char *needle, size_t needle_len) |
308 | { | 308 | { |
309 | size_t i; /* Index into current byte of NEEDLE. */ | 309 | size_t i; /* Index into current byte of NEEDLE. */ |
310 | size_t j; /* Index into current window of HAYSTACK. */ | 310 | size_t j; /* Index into current window of HAYSTACK. */ |
311 | size_t period; /* The period of the right half of needle. */ | 311 | size_t period; /* The period of the right half of needle. */ |
312 | size_t suffix; /* The index of the right half of needle. */ | 312 | size_t suffix; /* The index of the right half of needle. */ |
313 | size_t shift_table[1U << CHAR_BIT]; /* See below. */ | 313 | size_t shift_table[1U << CHAR_BIT]; /* See below. */ |
314 | 314 | ||
315 | /* Factor the needle into two halves, such that the left half is | 315 | /* Factor the needle into two halves, such that the left half is |
316 | smaller than the global period, and the right half is | 316 | 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, | |||
331 | if (CMP_FUNC (needle, needle + period, suffix) == 0) | 331 | if (CMP_FUNC (needle, needle + period, suffix) == 0) |
332 | { | 332 | { |
333 | /* Entire needle is periodic; a mismatch can only advance by the | 333 | /* Entire needle is periodic; a mismatch can only advance by the |
334 | period, so use memory to avoid rescanning known occurrences | 334 | period, so use memory to avoid rescanning known occurrences |
335 | of the period. */ | 335 | of the period. */ |
336 | size_t memory = 0; | 336 | size_t memory = 0; |
337 | size_t shift; | 337 | size_t shift; |
338 | j = 0; | 338 | j = 0; |
339 | while (AVAILABLE (haystack, haystack_len, j, needle_len)) | 339 | while (AVAILABLE (haystack, haystack_len, j, needle_len)) |
340 | { | 340 | { |
341 | /* Check the last byte first; if it does not match, then | 341 | /* Check the last byte first; if it does not match, then |
342 | shift to the next possible match location. */ | 342 | shift to the next possible match location. */ |
343 | shift = shift_table[CANON_ELEMENT (haystack[j + needle_len - 1])]; | 343 | shift = shift_table[CANON_ELEMENT (haystack[j + needle_len - 1])]; |
344 | if (0 < shift) | 344 | if (0 < shift) |
345 | { | 345 | { |
346 | if (memory && shift < period) | 346 | if (memory && shift < period) |
347 | { | 347 | { |
348 | /* Since needle is periodic, but the last period has | 348 | /* Since needle is periodic, but the last period has |
349 | a byte out of place, there can be no match until | 349 | a byte out of place, there can be no match until |
350 | after the mismatch. */ | 350 | after the mismatch. */ |
351 | shift = needle_len - period; | 351 | shift = needle_len - period; |
352 | memory = 0; | 352 | memory = 0; |
353 | } | 353 | } |
354 | j += shift; | 354 | j += shift; |
355 | continue; | 355 | continue; |
356 | } | 356 | } |
357 | /* Scan for matches in right half. The last byte has | 357 | /* Scan for matches in right half. The last byte has |
358 | already been matched, by virtue of the shift table. */ | 358 | already been matched, by virtue of the shift table. */ |
359 | i = MAX (suffix, memory); | 359 | i = MAX (suffix, memory); |
360 | while (i < needle_len - 1 && (CANON_ELEMENT (needle[i]) | 360 | while (i < needle_len - 1 && (CANON_ELEMENT (needle[i]) |
361 | == CANON_ELEMENT (haystack[i + j]))) | 361 | == CANON_ELEMENT (haystack[i + j]))) |
362 | ++i; | 362 | ++i; |
363 | if (needle_len - 1 <= i) | 363 | if (needle_len - 1 <= i) |
364 | { | 364 | { |
365 | /* Scan for matches in left half. */ | 365 | /* Scan for matches in left half. */ |
366 | i = suffix - 1; | 366 | i = suffix - 1; |
367 | while (memory < i + 1 && (CANON_ELEMENT (needle[i]) | 367 | while (memory < i + 1 && (CANON_ELEMENT (needle[i]) |
368 | == CANON_ELEMENT (haystack[i + j]))) | 368 | == CANON_ELEMENT (haystack[i + j]))) |
369 | --i; | 369 | --i; |
370 | if (i + 1 < memory + 1) | 370 | if (i + 1 < memory + 1) |
371 | return (RETURN_TYPE) (haystack + j); | 371 | return (RETURN_TYPE) (haystack + j); |
372 | /* No match, so remember how many repetitions of period | 372 | /* No match, so remember how many repetitions of period |
373 | on the right half were scanned. */ | 373 | on the right half were scanned. */ |
374 | j += period; | 374 | j += period; |
375 | memory = needle_len - period; | 375 | memory = needle_len - period; |
376 | } | 376 | } |
377 | else | 377 | else |
378 | { | 378 | { |
379 | j += i - suffix + 1; | 379 | j += i - suffix + 1; |
380 | memory = 0; | 380 | memory = 0; |
381 | } | 381 | } |
382 | } | 382 | } |
383 | } | 383 | } |
384 | else | 384 | else |
385 | { | 385 | { |
386 | /* The two halves of needle are distinct; no extra memory is | 386 | /* The two halves of needle are distinct; no extra memory is |
387 | required, and any mismatch results in a maximal shift. */ | 387 | required, and any mismatch results in a maximal shift. */ |
388 | size_t shift; | 388 | size_t shift; |
389 | period = MAX (suffix, needle_len - suffix) + 1; | 389 | period = MAX (suffix, needle_len - suffix) + 1; |
390 | j = 0; | 390 | j = 0; |
391 | while (AVAILABLE (haystack, haystack_len, j, needle_len)) | 391 | while (AVAILABLE (haystack, haystack_len, j, needle_len)) |
392 | { | 392 | { |
393 | /* Check the last byte first; if it does not match, then | 393 | /* Check the last byte first; if it does not match, then |
394 | shift to the next possible match location. */ | 394 | shift to the next possible match location. */ |
395 | shift = shift_table[CANON_ELEMENT (haystack[j + needle_len - 1])]; | 395 | shift = shift_table[CANON_ELEMENT (haystack[j + needle_len - 1])]; |
396 | if (0 < shift) | 396 | if (0 < shift) |
397 | { | 397 | { |
398 | j += shift; | 398 | j += shift; |
399 | continue; | 399 | continue; |
400 | } | 400 | } |
401 | /* Scan for matches in right half. The last byte has | 401 | /* Scan for matches in right half. The last byte has |
402 | already been matched, by virtue of the shift table. */ | 402 | already been matched, by virtue of the shift table. */ |
403 | i = suffix; | 403 | i = suffix; |
404 | while (i < needle_len - 1 && (CANON_ELEMENT (needle[i]) | 404 | while (i < needle_len - 1 && (CANON_ELEMENT (needle[i]) |
405 | == CANON_ELEMENT (haystack[i + j]))) | 405 | == CANON_ELEMENT (haystack[i + j]))) |
406 | ++i; | 406 | ++i; |
407 | if (needle_len - 1 <= i) | 407 | if (needle_len - 1 <= i) |
408 | { | 408 | { |
409 | /* Scan for matches in left half. */ | 409 | /* Scan for matches in left half. */ |
410 | i = suffix - 1; | 410 | i = suffix - 1; |
411 | while (i != SIZE_MAX && (CANON_ELEMENT (needle[i]) | 411 | while (i != SIZE_MAX && (CANON_ELEMENT (needle[i]) |
412 | == CANON_ELEMENT (haystack[i + j]))) | 412 | == CANON_ELEMENT (haystack[i + j]))) |
413 | --i; | 413 | --i; |
414 | if (i == SIZE_MAX) | 414 | if (i == SIZE_MAX) |
415 | return (RETURN_TYPE) (haystack + j); | 415 | return (RETURN_TYPE) (haystack + j); |
416 | j += period; | 416 | j += period; |
417 | } | 417 | } |
418 | else | 418 | else |
419 | j += i - suffix + 1; | 419 | j += i - suffix + 1; |
420 | } | 420 | } |
421 | } | 421 | } |
422 | return NULL; | 422 | return NULL; |
423 | } | 423 | } |
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, ...) | |||
102 | if ((daemon->options & MHD_USE_DEBUG) == 0) | 102 | if ((daemon->options & MHD_USE_DEBUG) == 0) |
103 | return; | 103 | return; |
104 | va_start (va, format); | 104 | va_start (va, format); |
105 | daemon->custom_error_log(daemon->custom_error_log_cls, | 105 | daemon->custom_error_log (daemon->custom_error_log_cls, format, va); |
106 | format, | ||
107 | va); | ||
108 | va_end (va); | 106 | va_end (va); |
109 | } | 107 | } |
110 | #endif | 108 | #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 | |||
143 | * Set to -1 if size is not known. | 143 | * Set to -1 if size is not known. |
144 | */ | 144 | */ |
145 | size_t total_size; | 145 | size_t total_size; |
146 | 146 | ||
147 | /** | 147 | /** |
148 | * Size of data. | 148 | * Size of data. |
149 | */ | 149 | */ |
@@ -153,7 +153,7 @@ struct MHD_Response | |||
153 | * Size of the data buffer. | 153 | * Size of the data buffer. |
154 | */ | 154 | */ |
155 | size_t data_buffer_size; | 155 | size_t data_buffer_size; |
156 | 156 | ||
157 | /** | 157 | /** |
158 | * At what offset in the stream is the | 158 | * At what offset in the stream is the |
159 | * beginning of data located? | 159 | * beginning of data located? |
@@ -224,7 +224,7 @@ enum MHD_CONNECTION_STATE | |||
224 | * rest. | 224 | * rest. |
225 | */ | 225 | */ |
226 | MHD_CONNECTION_FOOTER_PART_RECEIVED = MHD_CONNECTION_BODY_RECEIVED + 1, | 226 | MHD_CONNECTION_FOOTER_PART_RECEIVED = MHD_CONNECTION_BODY_RECEIVED + 1, |
227 | 227 | ||
228 | /** | 228 | /** |
229 | * 9: We received the entire footer. Wait for a response to be queued | 229 | * 9: We received the entire footer. Wait for a response to be queued |
230 | * and prepare the response headers. | 230 | * and prepare the response headers. |
@@ -353,7 +353,7 @@ struct MHD_Connection | |||
353 | * This is a linked list. | 353 | * This is a linked list. |
354 | */ | 354 | */ |
355 | struct MHD_Connection *next; | 355 | struct MHD_Connection *next; |
356 | 356 | ||
357 | /** | 357 | /** |
358 | * Reference to the MHD_Daemon struct. | 358 | * Reference to the MHD_Daemon struct. |
359 | */ | 359 | */ |
@@ -466,7 +466,7 @@ struct MHD_Connection | |||
466 | * Size of write_buffer (in bytes). | 466 | * Size of write_buffer (in bytes). |
467 | */ | 467 | */ |
468 | size_t write_buffer_size; | 468 | size_t write_buffer_size; |
469 | 469 | ||
470 | /** | 470 | /** |
471 | * Offset where we are with sending from write_buffer. | 471 | * Offset where we are with sending from write_buffer. |
472 | */ | 472 | */ |
@@ -571,19 +571,19 @@ struct MHD_Connection | |||
571 | * with respect to the current chunk (at what offset / position)? | 571 | * with respect to the current chunk (at what offset / position)? |
572 | */ | 572 | */ |
573 | unsigned int current_chunk_offset; | 573 | unsigned int current_chunk_offset; |
574 | 574 | ||
575 | /** | 575 | /** |
576 | * Handler used for processing read connection operations | 576 | * Handler used for processing read connection operations |
577 | */ | 577 | */ |
578 | int (*read_handler) (struct MHD_Connection * connection); | 578 | int (*read_handler) (struct MHD_Connection * connection); |
579 | 579 | ||
580 | /** | 580 | /** |
581 | * Handler used for processing write connection operations | 581 | * Handler used for processing write connection operations |
582 | */ | 582 | */ |
583 | int (*write_handler) (struct MHD_Connection * connection); | 583 | int (*write_handler) (struct MHD_Connection * connection); |
584 | 584 | ||
585 | /** | 585 | /** |
586 | * Handler used for processing idle connection operations | 586 | * Handler used for processing idle connection operations |
587 | */ | 587 | */ |
588 | int (*idle_handler) (struct MHD_Connection * connection); | 588 | int (*idle_handler) (struct MHD_Connection * connection); |
589 | 589 | ||
@@ -615,7 +615,7 @@ struct MHD_Daemon | |||
615 | * Callback function for all requests. | 615 | * Callback function for all requests. |
616 | */ | 616 | */ |
617 | MHD_AccessHandlerCallback default_handler; | 617 | MHD_AccessHandlerCallback default_handler; |
618 | 618 | ||
619 | /** | 619 | /** |
620 | * Closure argument to default_handler. | 620 | * Closure argument to default_handler. |
621 | */ | 621 | */ |
@@ -665,7 +665,7 @@ struct MHD_Daemon | |||
665 | 665 | ||
666 | #if HAVE_MESSAGES | 666 | #if HAVE_MESSAGES |
667 | /** | 667 | /** |
668 | * Function for logging error messages (if we | 668 | * Function for logging error messages (if we |
669 | * support error reporting). | 669 | * support error reporting). |
670 | */ | 670 | */ |
671 | void (*custom_error_log) (void *cls, const char *fmt, va_list va); | 671 | void (*custom_error_log) (void *cls, const char *fmt, va_list va); |
@@ -685,7 +685,7 @@ struct MHD_Daemon | |||
685 | * Listen socket. | 685 | * Listen socket. |
686 | */ | 686 | */ |
687 | int socket_fd; | 687 | int socket_fd; |
688 | 688 | ||
689 | /** | 689 | /** |
690 | * Are we shutting down? | 690 | * Are we shutting down? |
691 | */ | 691 | */ |
@@ -731,12 +731,12 @@ struct MHD_Daemon | |||
731 | enum MHD_GNUTLS_CredentialsType cred_type; | 731 | enum MHD_GNUTLS_CredentialsType cred_type; |
732 | 732 | ||
733 | /** | 733 | /** |
734 | * Server x509 credentials | 734 | * Server x509 credentials |
735 | */ | 735 | */ |
736 | MHD_gtls_cert_credentials_t x509_cred; | 736 | MHD_gtls_cert_credentials_t x509_cred; |
737 | 737 | ||
738 | /** | 738 | /** |
739 | * Cipher priority cache | 739 | * Cipher priority cache |
740 | */ | 740 | */ |
741 | MHD_gnutls_priority_t priority_cache; | 741 | MHD_gnutls_priority_t priority_cache; |
742 | 742 | ||
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, | |||
925 | * @param key the header to look for | 925 | * @param key the header to look for |
926 | * @return NULL if no such item was found | 926 | * @return NULL if no such item was found |
927 | */ | 927 | */ |
928 | const char * | 928 | const char *MHD_lookup_connection_value (struct MHD_Connection *connection, |
929 | MHD_lookup_connection_value (struct MHD_Connection *connection, | 929 | enum MHD_ValueKind kind, |
930 | enum MHD_ValueKind kind, | 930 | const char *key); |
931 | const char *key); | ||
932 | 931 | ||
933 | /** | 932 | /** |
934 | * Queue a response to be transmitted to the client (as soon as | 933 | * 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, | |||
82 | *unused = NULL; | 82 | *unused = NULL; |
83 | ret = 0; | 83 | ret = 0; |
84 | 84 | ||
85 | hdr = MHD_lookup_connection_value (connection, | 85 | hdr = MHD_lookup_connection_value (connection, MHD_COOKIE_KIND, "name1"); |
86 | MHD_COOKIE_KIND, | 86 | if ((hdr == NULL) || (0 != strcmp (hdr, "var1"))) |
87 | "name1"); | 87 | abort (); |
88 | if ( (hdr == NULL) || | 88 | hdr = MHD_lookup_connection_value (connection, MHD_COOKIE_KIND, "name2"); |
89 | (0 != strcmp(hdr, "var1")) ) | 89 | if ((hdr == NULL) || (0 != strcmp (hdr, "var2"))) |
90 | abort(); | 90 | abort (); |
91 | hdr = MHD_lookup_connection_value (connection, | 91 | hdr = MHD_lookup_connection_value (connection, MHD_COOKIE_KIND, "name3"); |
92 | MHD_COOKIE_KIND, | 92 | if ((hdr == NULL) || (0 != strcmp (hdr, ""))) |
93 | "name2"); | 93 | abort (); |
94 | if ( (hdr == NULL) || | 94 | hdr = MHD_lookup_connection_value (connection, MHD_COOKIE_KIND, "name4"); |
95 | (0 != strcmp(hdr, "var2")) ) | 95 | if ((hdr == NULL) || (0 != strcmp (hdr, "var4 with spaces"))) |
96 | abort(); | 96 | abort (); |
97 | hdr = MHD_lookup_connection_value (connection, | ||
98 | MHD_COOKIE_KIND, | ||
99 | "name3"); | ||
100 | if ( (hdr == NULL) || | ||
101 | (0 != strcmp(hdr, "")) ) | ||
102 | abort(); | ||
103 | hdr = MHD_lookup_connection_value (connection, | ||
104 | MHD_COOKIE_KIND, | ||
105 | "name4"); | ||
106 | if ( (hdr == NULL) || | ||
107 | (0 != strcmp(hdr, "var4 with spaces")) ) | ||
108 | abort(); | ||
109 | response = MHD_create_response_from_data (strlen (url), | 97 | response = MHD_create_response_from_data (strlen (url), |
110 | (void *) url, MHD_NO, MHD_YES); | 98 | (void *) url, MHD_NO, MHD_YES); |
111 | ret = MHD_queue_response (connection, MHD_HTTP_OK, response); | 99 | ret = MHD_queue_response (connection, MHD_HTTP_OK, response); |
@@ -145,12 +133,12 @@ testExternalGet () | |||
145 | curl_easy_setopt (c, CURLOPT_URL, "http://localhost:21080/hello_world"); | 133 | curl_easy_setopt (c, CURLOPT_URL, "http://localhost:21080/hello_world"); |
146 | curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); | 134 | curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); |
147 | curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); | 135 | curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); |
148 | curl_easy_setopt (c, CURLOPT_FAILONERROR, 1); | 136 | curl_easy_setopt (c, CURLOPT_FAILONERROR, 1); |
149 | /* note that the string below intentionally uses the | 137 | /* note that the string below intentionally uses the |
150 | various ways cookies can be specified to exercise the | 138 | various ways cookies can be specified to exercise the |
151 | parser! Do not change! */ | 139 | parser! Do not change! */ |
152 | curl_easy_setopt (c, CURLOPT_COOKIE, | 140 | curl_easy_setopt (c, CURLOPT_COOKIE, |
153 | "name1=var1; name2=var2,name3 ;name4=\"var4 with spaces\";"); | 141 | "name1=var1; name2=var2,name3 ;name4=\"var4 with spaces\";"); |
154 | if (oneone) | 142 | if (oneone) |
155 | curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); | 143 | curl_easy_setopt (c, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); |
156 | else | 144 | else |
@@ -158,8 +146,8 @@ testExternalGet () | |||
158 | curl_easy_setopt (c, CURLOPT_TIMEOUT, 150L); | 146 | curl_easy_setopt (c, CURLOPT_TIMEOUT, 150L); |
159 | curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT, 15L); | 147 | curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT, 15L); |
160 | /* NOTE: use of CONNECTTIMEOUT without also | 148 | /* NOTE: use of CONNECTTIMEOUT without also |
161 | setting NOSIGNAL results in really weird | 149 | setting NOSIGNAL results in really weird |
162 | crashes on my system! */ | 150 | crashes on my system! */ |
163 | curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1); | 151 | curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1); |
164 | 152 | ||
165 | 153 | ||
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) | |||
57 | return size * nmemb; | 57 | return size * nmemb; |
58 | } | 58 | } |
59 | 59 | ||
60 | static int | 60 | static int |
61 | kv_cb(void * cls, | 61 | kv_cb (void *cls, enum MHD_ValueKind kind, const char *key, const char *value) |
62 | enum MHD_ValueKind kind, | ||
63 | const char * key, | ||
64 | const char * value) | ||
65 | { | 62 | { |
66 | if ( (0 == strcmp(key, MHD_HTTP_HEADER_HOST)) && | 63 | if ((0 == strcmp (key, MHD_HTTP_HEADER_HOST)) && |
67 | (0 == strcmp(value, "localhost:21080")) && | 64 | (0 == strcmp (value, "localhost:21080")) && (kind == MHD_HEADER_KIND)) |
68 | (kind == MHD_HEADER_KIND) ) | ||
69 | { | 65 | { |
70 | *((int*) cls) = 1; | 66 | *((int *) cls) = 1; |
71 | return MHD_NO; | 67 | return MHD_NO; |
72 | } | 68 | } |
73 | return MHD_YES; | 69 | return MHD_YES; |
@@ -97,61 +93,41 @@ ahc_echo (void *cls, | |||
97 | } | 93 | } |
98 | *unused = NULL; | 94 | *unused = NULL; |
99 | ret = 0; | 95 | ret = 0; |
100 | MHD_get_connection_values (connection, | 96 | MHD_get_connection_values (connection, MHD_HEADER_KIND, &kv_cb, &ret); |
101 | MHD_HEADER_KIND, | ||
102 | &kv_cb, | ||
103 | &ret); | ||
104 | if (ret != 1) | 97 | if (ret != 1) |
105 | abort(); | 98 | abort (); |
106 | hdr = MHD_lookup_connection_value (connection, | 99 | hdr = MHD_lookup_connection_value (connection, MHD_HEADER_KIND, "NotFound"); |
107 | MHD_HEADER_KIND, | ||
108 | "NotFound"); | ||
109 | if (hdr != NULL) | 100 | if (hdr != NULL) |
110 | abort(); | 101 | abort (); |
111 | hdr = MHD_lookup_connection_value (connection, | 102 | hdr = MHD_lookup_connection_value (connection, |
112 | MHD_HEADER_KIND, | 103 | MHD_HEADER_KIND, MHD_HTTP_HEADER_ACCEPT); |
113 | MHD_HTTP_HEADER_ACCEPT); | 104 | if ((hdr == NULL) || (0 != strcmp (hdr, "*/*"))) |
114 | if ( (hdr == NULL) || | 105 | abort (); |
115 | (0 != strcmp(hdr, "*/*")) ) | 106 | hdr = MHD_lookup_connection_value (connection, |
116 | abort(); | 107 | MHD_HEADER_KIND, MHD_HTTP_HEADER_HOST); |
117 | hdr = MHD_lookup_connection_value (connection, | 108 | if ((hdr == NULL) || (0 != strcmp (hdr, "localhost:21080"))) |
118 | MHD_HEADER_KIND, | 109 | abort (); |
119 | MHD_HTTP_HEADER_HOST); | 110 | MHD_set_connection_value (connection, |
120 | if ( (hdr == NULL) || | 111 | MHD_HEADER_KIND, "FakeHeader", "NowPresent"); |
121 | (0 != strcmp(hdr, "localhost:21080")) ) | 112 | hdr = MHD_lookup_connection_value (connection, |
122 | abort(); | 113 | MHD_HEADER_KIND, "FakeHeader"); |
123 | MHD_set_connection_value (connection, | 114 | if ((hdr == NULL) || (0 != strcmp (hdr, "NowPresent"))) |
124 | MHD_HEADER_KIND, | 115 | abort (); |
125 | "FakeHeader", | ||
126 | "NowPresent"); | ||
127 | hdr = MHD_lookup_connection_value (connection, | ||
128 | MHD_HEADER_KIND, | ||
129 | "FakeHeader"); | ||
130 | if ( (hdr == NULL) || | ||
131 | (0 != strcmp(hdr, "NowPresent")) ) | ||
132 | abort(); | ||
133 | 116 | ||
134 | response = MHD_create_response_from_data (strlen (url), | 117 | response = MHD_create_response_from_data (strlen (url), |
135 | (void *) url, MHD_NO, MHD_YES); | 118 | (void *) url, MHD_NO, MHD_YES); |
136 | MHD_add_response_header (response, | 119 | MHD_add_response_header (response, "MyHeader", "MyValue"); |
137 | "MyHeader", | ||
138 | "MyValue"); | ||
139 | hdr = MHD_get_response_header (response, "MyHeader"); | 120 | hdr = MHD_get_response_header (response, "MyHeader"); |
140 | if (0 != strcmp ("MyValue", hdr)) | 121 | if (0 != strcmp ("MyValue", hdr)) |
141 | abort(); | 122 | abort (); |
142 | MHD_add_response_header (response, | 123 | MHD_add_response_header (response, "MyHeader", "MyValueToo"); |
143 | "MyHeader", | 124 | if (MHD_YES != MHD_del_response_header (response, "MyHeader", "MyValue")) |
144 | "MyValueToo"); | 125 | abort (); |
145 | if (MHD_YES != | ||
146 | MHD_del_response_header (response, | ||
147 | "MyHeader", | ||
148 | "MyValue")) | ||
149 | abort(); | ||
150 | hdr = MHD_get_response_header (response, "MyHeader"); | 126 | hdr = MHD_get_response_header (response, "MyHeader"); |
151 | if (0 != strcmp ("MyValueToo", hdr)) | 127 | if (0 != strcmp ("MyValueToo", hdr)) |
152 | abort(); | 128 | abort (); |
153 | if (1 != MHD_get_response_headers (response, NULL, NULL)) | 129 | if (1 != MHD_get_response_headers (response, NULL, NULL)) |
154 | abort(); | 130 | abort (); |
155 | ret = MHD_queue_response (connection, MHD_HTTP_OK, response); | 131 | ret = MHD_queue_response (connection, MHD_HTTP_OK, response); |
156 | MHD_destroy_response (response); | 132 | MHD_destroy_response (response); |
157 | if (ret == MHD_NO) | 133 | if (ret == MHD_NO) |
@@ -297,8 +273,8 @@ testExternalGet () | |||
297 | curl_easy_setopt (c, CURLOPT_TIMEOUT, 150L); | 273 | curl_easy_setopt (c, CURLOPT_TIMEOUT, 150L); |
298 | curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT, 15L); | 274 | curl_easy_setopt (c, CURLOPT_CONNECTTIMEOUT, 15L); |
299 | /* NOTE: use of CONNECTTIMEOUT without also | 275 | /* NOTE: use of CONNECTTIMEOUT without also |
300 | setting NOSIGNAL results in really weird | 276 | setting NOSIGNAL results in really weird |
301 | crashes on my system! */ | 277 | crashes on my system! */ |
302 | curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1); | 278 | curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1); |
303 | 279 | ||
304 | 280 | ||
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) | |||
151 | fprintf (stderr, MHD_E_MEM); | 151 | fprintf (stderr, MHD_E_MEM); |
152 | return -1; | 152 | return -1; |
153 | } | 153 | } |
154 | if (getcwd (doc_path, doc_path_len) == NULL) | 154 | if (getcwd (doc_path, doc_path_len) == NULL) |
155 | { | 155 | { |
156 | fclose (test_fd); | 156 | fclose (test_fd); |
157 | free (doc_path); | 157 | 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, | |||
147 | fprintf (stderr, MHD_E_MEM); | 147 | fprintf (stderr, MHD_E_MEM); |
148 | return -1; | 148 | return -1; |
149 | } | 149 | } |
150 | if (getcwd (doc_path, doc_path_len) == NULL) | 150 | if (getcwd (doc_path, doc_path_len) == NULL) |
151 | { | 151 | { |
152 | fclose (test_fd); | 152 | fclose (test_fd); |
153 | free (doc_path); | 153 | 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) | |||
148 | fprintf (stderr, MHD_E_MEM); | 148 | fprintf (stderr, MHD_E_MEM); |
149 | return -1; | 149 | return -1; |
150 | } | 150 | } |
151 | if (getcwd (doc_path, doc_path_len) == NULL) | 151 | if (getcwd (doc_path, doc_path_len) == NULL) |
152 | { | 152 | { |
153 | fclose (test_fd); | 153 | fclose (test_fd); |
154 | free (doc_path); | 154 | 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) | |||
303 | /* TODO test_wrap: change sig to (setup_func, test, va_list test_arg) & move to test_util.c */ | 303 | /* TODO test_wrap: change sig to (setup_func, test, va_list test_arg) & move to test_util.c */ |
304 | static int | 304 | static int |
305 | test_wrap (char *test_name, int | 305 | test_wrap (char *test_name, int |
306 | (*test_function) (FILE * test_fd, char *cipher_suite, int proto_version), | 306 | (*test_function) (FILE * test_fd, char *cipher_suite, |
307 | FILE * test_fd, int daemon_flags, char *cipher_suite, | 307 | int proto_version), FILE * test_fd, |
308 | int proto_version, ...) | 308 | int daemon_flags, char *cipher_suite, int proto_version, ...) |
309 | { | 309 | { |
310 | int ret; | 310 | int ret; |
311 | va_list arg_list; | 311 | 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 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libmicrohttpd | 2 | This file is part of libmicrohttpd |
3 | (C) 2007 Christian Grothoff | 3 | (C) 2007 Christian Grothoff |
4 | 4 | ||
5 | libmicrohttpd is free software; you can redistribute it and/or modify | 5 | libmicrohttpd is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published | 6 | it under the terms of the GNU General Public License as published |
7 | by the Free Software Foundation; either version 2, or (at your | 7 | by the Free Software Foundation; either version 2, or (at your |
8 | option) any later version. | 8 | option) any later version. |
9 | 9 | ||
10 | libmicrohttpd is distributed in the hope that it will be useful, but | 10 | libmicrohttpd is distributed in the hope that it will be useful, but |
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | General Public License for more details. | 13 | General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with libmicrohttpd; see the file COPYING. If not, write to the | 16 | along with libmicrohttpd; see the file COPYING. If not, write to the |
17 | Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
@@ -23,8 +23,8 @@ | |||
23 | * @brief Testcase for libmicrohttpd HTTPS GET operations | 23 | * @brief Testcase for libmicrohttpd HTTPS GET operations |
24 | * @author Sagie Amir | 24 | * @author Sagie Amir |
25 | * @author Christian Grothoff | 25 | * @author Christian Grothoff |
26 | * | 26 | * |
27 | * TODO: add test for external select! | 27 | * TODO: add test for external select! |
28 | */ | 28 | */ |
29 | 29 | ||
30 | #include "platform.h" | 30 | #include "platform.h" |
@@ -268,7 +268,7 @@ https_transfer_thread_adapter (void *args) | |||
268 | /* time spread incomming requests */ | 268 | /* time spread incomming requests */ |
269 | usleep ((useconds_t) 10.0 * ((double) rand ()) / ((double) RAND_MAX)); | 269 | usleep ((useconds_t) 10.0 * ((double) rand ()) / ((double) RAND_MAX)); |
270 | ret = test_https_transfer (cargs->test_fd, | 270 | ret = test_https_transfer (cargs->test_fd, |
271 | cargs->cipher_suite, cargs->proto_version); | 271 | cargs->cipher_suite, cargs->proto_version); |
272 | if (ret == 0) | 272 | if (ret == 0) |
273 | return NULL; | 273 | return NULL; |
274 | return &nonnull; | 274 | return &nonnull; |
@@ -326,9 +326,9 @@ teardown (struct MHD_Daemon *d) | |||
326 | /* TODO test_wrap: change sig to (setup_func, test, va_list test_arg) & move to test_util.c */ | 326 | /* TODO test_wrap: change sig to (setup_func, test, va_list test_arg) & move to test_util.c */ |
327 | static int | 327 | static int |
328 | test_wrap (char *test_name, int | 328 | test_wrap (char *test_name, int |
329 | (*test_function) (FILE * test_fd, char *cipher_suite, int proto_version), | 329 | (*test_function) (FILE * test_fd, char *cipher_suite, |
330 | FILE * test_fd, int daemon_flags, char *cipher_suite, | 330 | int proto_version), FILE * test_fd, |
331 | int proto_version, ...) | 331 | int daemon_flags, char *cipher_suite, int proto_version, ...) |
332 | { | 332 | { |
333 | int ret; | 333 | int ret; |
334 | va_list arg_list; | 334 | va_list arg_list; |
@@ -367,14 +367,15 @@ test_wrap (char *test_name, int | |||
367 | */ | 367 | */ |
368 | static int | 368 | static int |
369 | test_single_client (FILE * test_fd, char *cipher_suite, | 369 | test_single_client (FILE * test_fd, char *cipher_suite, |
370 | int curl_proto_version) | 370 | int curl_proto_version) |
371 | { | 371 | { |
372 | void *client_thread_ret; | 372 | void *client_thread_ret; |
373 | struct https_test_data client_args = {test_fd, cipher_suite, curl_proto_version}; | 373 | struct https_test_data client_args = |
374 | { test_fd, cipher_suite, curl_proto_version }; | ||
374 | 375 | ||
375 | client_thread_ret = https_transfer_thread_adapter (&client_args); | 376 | client_thread_ret = https_transfer_thread_adapter (&client_args); |
376 | if (client_thread_ret != NULL) | 377 | if (client_thread_ret != NULL) |
377 | return -1; | 378 | return -1; |
378 | return 0; | 379 | return 0; |
379 | } | 380 | } |
380 | 381 | ||
@@ -388,18 +389,20 @@ test_single_client (FILE * test_fd, char *cipher_suite, | |||
388 | */ | 389 | */ |
389 | static int | 390 | static int |
390 | test_parallel_clients (FILE * test_fd, char *cipher_suite, | 391 | test_parallel_clients (FILE * test_fd, char *cipher_suite, |
391 | int curl_proto_version) | 392 | int curl_proto_version) |
392 | { | 393 | { |
393 | int i; | 394 | int i; |
394 | int client_count = 3; | 395 | int client_count = 3; |
395 | void *client_thread_ret; | 396 | void *client_thread_ret; |
396 | pthread_t client_arr[client_count]; | 397 | pthread_t client_arr[client_count]; |
397 | struct https_test_data client_args = {test_fd, cipher_suite, curl_proto_version}; | 398 | struct https_test_data client_args = |
399 | { test_fd, cipher_suite, curl_proto_version }; | ||
398 | 400 | ||
399 | for (i = 0; i < client_count; ++i) | 401 | for (i = 0; i < client_count; ++i) |
400 | { | 402 | { |
401 | if (pthread_create (&client_arr[i], NULL, | 403 | if (pthread_create (&client_arr[i], NULL, |
402 | (void * ) &https_transfer_thread_adapter, &client_args) != 0) | 404 | (void *) &https_transfer_thread_adapter, |
405 | &client_args) != 0) | ||
403 | { | 406 | { |
404 | fprintf (stderr, "Error: failed to spawn test client threads.\n"); | 407 | fprintf (stderr, "Error: failed to spawn test client threads.\n"); |
405 | return -1; | 408 | return -1; |
@@ -410,8 +413,8 @@ test_parallel_clients (FILE * test_fd, char *cipher_suite, | |||
410 | for (i = 0; i < client_count; ++i) | 413 | for (i = 0; i < client_count; ++i) |
411 | { | 414 | { |
412 | if ((pthread_join (client_arr[i], &client_thread_ret) != 0) || | 415 | if ((pthread_join (client_arr[i], &client_thread_ret) != 0) || |
413 | (client_thread_ret != NULL) ) | 416 | (client_thread_ret != NULL)) |
414 | return -1; | 417 | return -1; |
415 | } | 418 | } |
416 | 419 | ||
417 | return 0; | 420 | return 0; |
@@ -429,7 +432,7 @@ main (int argc, char *const *argv) | |||
429 | srand (iseed); | 432 | srand (iseed); |
430 | 433 | ||
431 | if (curl_check_version (MHD_REQ_CURL_VERSION)) | 434 | if (curl_check_version (MHD_REQ_CURL_VERSION)) |
432 | return -1; | 435 | return -1; |
433 | 436 | ||
434 | if ((test_fd = setupTestFile ()) == NULL) | 437 | if ((test_fd = setupTestFile ()) == NULL) |
435 | { | 438 | { |
@@ -444,34 +447,34 @@ main (int argc, char *const *argv) | |||
444 | } | 447 | } |
445 | 448 | ||
446 | errorCount += | 449 | errorCount += |
447 | test_wrap ("multi threaded daemon, single client", &test_single_client, test_fd, | 450 | test_wrap ("multi threaded daemon, single client", &test_single_client, |
448 | MHD_USE_SSL | MHD_USE_DEBUG, "AES256-SHA", | 451 | test_fd, MHD_USE_SSL | MHD_USE_DEBUG, "AES256-SHA", |
449 | CURL_SSLVERSION_TLSv1, MHD_OPTION_HTTPS_MEM_KEY, srv_key_pem, | 452 | CURL_SSLVERSION_TLSv1, MHD_OPTION_HTTPS_MEM_KEY, srv_key_pem, |
450 | MHD_OPTION_HTTPS_MEM_CERT, srv_self_signed_cert_pem, | 453 | MHD_OPTION_HTTPS_MEM_CERT, srv_self_signed_cert_pem, |
451 | MHD_OPTION_END); | 454 | MHD_OPTION_END); |
452 | 455 | ||
453 | errorCount += | 456 | errorCount += |
454 | test_wrap ("single threaded daemon, single client", &test_single_client, test_fd, | 457 | test_wrap ("single threaded daemon, single client", &test_single_client, |
455 | MHD_USE_SELECT_INTERNALLY | | 458 | test_fd, |
456 | MHD_USE_SSL | MHD_USE_DEBUG, "AES256-SHA", | 459 | MHD_USE_SELECT_INTERNALLY | MHD_USE_SSL | MHD_USE_DEBUG, |
457 | CURL_SSLVERSION_TLSv1, MHD_OPTION_HTTPS_MEM_KEY, srv_key_pem, | 460 | "AES256-SHA", CURL_SSLVERSION_TLSv1, MHD_OPTION_HTTPS_MEM_KEY, |
458 | MHD_OPTION_HTTPS_MEM_CERT, srv_self_signed_cert_pem, | 461 | srv_key_pem, MHD_OPTION_HTTPS_MEM_CERT, |
459 | MHD_OPTION_END); | 462 | srv_self_signed_cert_pem, MHD_OPTION_END); |
460 | 463 | ||
461 | errorCount += | 464 | errorCount += |
462 | test_wrap ("multi threaded daemon, parallel client", &test_parallel_clients, test_fd, | 465 | test_wrap ("multi threaded daemon, parallel client", |
463 | MHD_USE_SSL | MHD_USE_DEBUG, "AES256-SHA", | 466 | &test_parallel_clients, test_fd, MHD_USE_SSL | MHD_USE_DEBUG, |
464 | CURL_SSLVERSION_TLSv1, MHD_OPTION_HTTPS_MEM_KEY, srv_key_pem, | 467 | "AES256-SHA", CURL_SSLVERSION_TLSv1, MHD_OPTION_HTTPS_MEM_KEY, |
465 | MHD_OPTION_HTTPS_MEM_CERT, srv_self_signed_cert_pem, | 468 | srv_key_pem, MHD_OPTION_HTTPS_MEM_CERT, |
466 | MHD_OPTION_END); | 469 | srv_self_signed_cert_pem, MHD_OPTION_END); |
467 | 470 | ||
468 | errorCount += | 471 | errorCount += |
469 | test_wrap ("single threaded daemon, parallel clients", &test_parallel_clients, test_fd, | 472 | test_wrap ("single threaded daemon, parallel clients", |
470 | MHD_USE_SELECT_INTERNALLY | | 473 | &test_parallel_clients, test_fd, |
471 | MHD_USE_SSL | MHD_USE_DEBUG, "AES256-SHA", | 474 | MHD_USE_SELECT_INTERNALLY | MHD_USE_SSL | MHD_USE_DEBUG, |
472 | CURL_SSLVERSION_TLSv1, MHD_OPTION_HTTPS_MEM_KEY, srv_key_pem, | 475 | "AES256-SHA", CURL_SSLVERSION_TLSv1, MHD_OPTION_HTTPS_MEM_KEY, |
473 | MHD_OPTION_HTTPS_MEM_CERT, srv_self_signed_cert_pem, | 476 | srv_key_pem, MHD_OPTION_HTTPS_MEM_CERT, |
474 | MHD_OPTION_END); | 477 | srv_self_signed_cert_pem, MHD_OPTION_END); |
475 | 478 | ||
476 | if (errorCount != 0) | 479 | if (errorCount != 0) |
477 | fprintf (stderr, "Failed test: %s.\n", argv[0]); | 480 | fprintf (stderr, "Failed test: %s.\n", argv[0]); |