int LLVMFuzzerInitialize(int *argc, char ***argv);
int
-LLVMFuzzerInitialize(int *argc, char ***argv) {
- // Silence unused args warning.
+LLVMFuzzerInitialize(int *argc, char ***argv)
+{
+ // Silence unused args warning.
(void)(argc);
(void)(argv);
civetweb_init();
- return 0;
+ return 0;
}
#if defined(TEST_FUZZ1)
{
static char URI[1024 * 64]; /* static, to avoid stack overflow */
- if (size+1 < sizeof(URI)) {
+ if (size + 1 < sizeof(URI)) {
memcpy(URI, data, size);
URI[size] = 0;
} else {
int LLVMFuzzerInitialize(int *argc, char ***argv);
int
-LLVMFuzzerInitialize(int *argc, char ***argv) {
- // Silence unused args warning.
+LLVMFuzzerInitialize(int *argc, char ***argv)
+{
+ // Silence unused args warning.
(void)(argc);
(void)(argv);
mock_server_init();
- return 0;
+ return 0;
}
#endif
#if !defined(OPENSSL_API_1_0) && !defined(OPENSSL_API_1_1) \
&& !defined(OPENSSL_API_3_0) && !defined(USE_MBEDTLS) \
- && !defined(USE_GNUTLS)
+ && !defined(USE_GNUTLS)
#error "Please define OPENSSL_API_#_# or USE_MBEDTLS or USE_GNUTLS"
#endif
#if defined(OPENSSL_API_1_0) && defined(OPENSSL_API_1_1)
} else
#elif defined(USE_GNUTLS)
if (ssl != NULL) {
- n = gtls_ssl_write(ssl, (const unsigned char *)buf, (size_t) len);
+ n = gtls_ssl_write(ssl, (const unsigned char *)buf, (size_t)len);
if (n < 0) {
- fprintf(stderr, "SSL write failed (%d): %s", n, gnutls_strerror(n));
+ fprintf(stderr,
+ "SSL write failed (%d): %s",
+ n,
+ gnutls_strerror(n));
return -2;
} else {
err = 0;
if (pollres > 0) {
nread = gtls_ssl_read(conn->ssl, (unsigned char *)buf, to_read);
if (nread < 0) {
- fprintf(stderr, "SSL read failed (%d): %s", nread, gnutls_strerror(nread));
+ fprintf(stderr,
+ "SSL read failed (%d): %s",
+ nread,
+ gnutls_strerror(nread));
return -2;
} else {
err = 0;
return 0;
}
-#if !defined(NO_SSL) && !defined(USE_MBEDTLS) && !defined(USE_GNUTLS) && !defined(NO_SSL_DL)
+#if !defined(NO_SSL) && !defined(USE_MBEDTLS) && !defined(USE_GNUTLS) \
+ && !defined(NO_SSL_DL)
#if defined(OPENSSL_API_1_1) || defined(OPENSSL_API_3_0)
if (use_ssl && (TLS_client_method == NULL)) {
if (error != NULL) {
portsTotal);
if (so.is_optional) {
portsOk++; /* it's okay if we couldn't create a socket,
- this port is optional anyway */
+ this port is optional anyway */
}
continue;
}
close_connection(conn);
-#if !defined(NO_SSL) && !defined(USE_MBEDTLS) && !defined(USE_GNUTLS) // TODO: mbedTLS client
+#if !defined(NO_SSL) && !defined(USE_MBEDTLS) \
+ && !defined(USE_GNUTLS) // TODO: mbedTLS client
if (((conn->phys_ctx->context_type == CONTEXT_HTTP_CLIENT)
|| (conn->phys_ctx->context_type == CONTEXT_WS_CLIENT))
&& (conn->phys_ctx->dd.ssl_ctx != NULL)) {
return NULL;
}
-#if !defined(NO_SSL) && !defined(USE_MBEDTLS) && !defined(USE_GNUTLS) // TODO: mbedTLS client
+#if !defined(NO_SSL) && !defined(USE_MBEDTLS) \
+ && !defined(USE_GNUTLS) // TODO: mbedTLS client
#if (defined(OPENSSL_API_1_1) || defined(OPENSSL_API_3_0)) \
&& !defined(NO_SSL_DL)
error->text_buffer_size,
"Can not create mutex");
}
-#if !defined(NO_SSL) && !defined(USE_MBEDTLS) && !defined(USE_GNUTLS) // TODO: mbedTLS client
+#if !defined(NO_SSL) && !defined(USE_MBEDTLS) \
+ && !defined(USE_GNUTLS) // TODO: mbedTLS client
SSL_CTX_free(conn->dom_ctx->ssl_ctx);
#endif
closesocket(sock);
return NULL;
}
-#if !defined(NO_SSL) && !defined(USE_MBEDTLS) && !defined(USE_GNUTLS) // TODO: mbedTLS client
+#if !defined(NO_SSL) && !defined(USE_MBEDTLS) \
+ && !defined(USE_GNUTLS) // TODO: mbedTLS client
if (use_ssl) {
/* TODO: Check ssl_verify_peer and ssl_ca_path here.
* SSL_CTX_set_verify call is needed to switch off server
sizeof(block),
",%s\"os\" : \"%s %s\"",
eol,
- "RTEMS",
+ "RTEMS",
rtems_version());
system_info_length += mg_str_append(&buffer, end, block);
#elif defined(__ZEPHYR__)
/* after the transport padding, if the boundary isn't
* immediately followed by a \r\n then it is either... */
- if (strncmp(boundary_end, "\r\n", 2))
- {
+ if (strncmp(boundary_end, "\r\n", 2)) {
/* ...the final boundary, and it is followed by --, (in which
* case it's the end of the request) or it's a malformed
* request */
CIVETWEB_API void gtls_sslctx_uninit(SSL_CTX *ctx);
CIVETWEB_API void gtls_ssl_close(SSL *ssl);
CIVETWEB_API int gtls_ssl_accept(SSL **ssl,
- SSL_CTX *ssl_ctx,
- int sock,
- struct mg_context *phys_ctx);
+ SSL_CTX *ssl_ctx,
+ int sock,
+ struct mg_context *phys_ctx);
CIVETWEB_API int gtls_ssl_read(SSL *ssl, unsigned char *buf, size_t len);
CIVETWEB_API int gtls_ssl_write(SSL *ssl, const unsigned char *buf, size_t len);
#include "civetweb_private_lua.h"
/* Prototypes */
-static int
-lua_error_handler(lua_State *L);
+static int lua_error_handler(lua_State *L);
#if defined(_WIN32)
static void *
/* Initialize a new HTTP response, either with some-predefined
* status code (e.g. 404 if this is called from an error
* handler) or with 200 OK */
- mg_response_header_start(conn, conn->status_code > 0 ? conn->status_code : 200);
+ mg_response_header_start(conn,
+ conn->status_code > 0 ? conn->status_code
+ : 200);
/* Add additional headers */
send_no_cache_header(conn);
send_additional_header(conn);
/* Add content type */
- mg_response_header_add(conn, "Content-Type", "text/html; charset=utf-8", -1);
+ mg_response_header_add(conn,
+ "Content-Type",
+ "text/html; charset=utf-8",
+ -1);
/* Send the HTTP response (status and all headers) */
mg_response_header_send(conn);
} else {
/* Success loading chunk. Call it. */
lua_ok = lua_pcall(L, 0, 0, 0);
- if(lua_ok != LUA_OK)
- {
+ if (lua_ok != LUA_OK) {
lua_cry(conn, lua_ok, L, "LSP Kepler", "call");
lua_error_handler(L);
return 1;
} else {
/* Success loading chunk. Call it. */
lua_ok = lua_pcall(L, 0, 0, 0);
- if(lua_ok != LUA_OK)
- {
+ if (lua_ok != LUA_OK) {
lua_cry(conn, lua_ok, L, "LSP", "call");
lua_error_handler(L);
return 1;
lua_pushstring(L, error_msg);
lua_pushliteral(L, "\n");
lua_call(L, 2, 0); /* call mg.write(error_msg + \n) */
- lua_pop(L, 1); /* pop mg */
+ lua_pop(L, 1); /* pop mg */
/* Get Lua traceback */
lua_getglobal(L, "debug");
/* Only print the traceback if it is not empty */
if (strcmp(lua_tostring(L, -1), "stack traceback:") != 0) {
lua_pushliteral(L, "\n"); /* append a newline */
- lua_call(L, 2, 0); /* call mg.write(traceback + \n) */
- lua_pop(L, 2); /* pop mg and traceback */
+ lua_call(L, 2, 0); /* call mg.write(traceback + \n) */
+ lua_pop(L, 2); /* pop mg and traceback */
} else {
lua_pop(L, 3); /* pop mg, traceback and error message */
}
*/
const psa_status_t status = psa_crypto_init();
if (status != PSA_SUCCESS) {
- DEBUG_TRACE("Failed to initialize PSA crypto, returned %d\n", (int) status);
+ DEBUG_TRACE("Failed to initialize PSA crypto, returned %d\n",
+ (int)status);
return -1;
}
#endif
* while Ubuntu Xenial, Ubuntu Trusty and Windows test containers at
* Travis CI do not. Maybe it is OpenSSL version specific.
*/
-#if defined(OPENSSL_API_1_1) || defined(OPENSSL_API_3_0)
+#if defined(OPENSSL_API_1_1) || defined(OPENSSL_API_3_0)
if (client_conn) {
/* Connect succeeds, but the connection is unusable. */
mg_printf(client_conn, "GET / HTTP/1.0\r\n\r\n");
/* Handle form: "POST multipart/form-data" without trailing CRLF*/
multipart_body =
- "--multipart-form-data-boundary--see-RFC-2388\r\n"
+ "--multipart-form-data-boundary--see-RFC-2388\r\n"
"Content-Disposition: form-data; name=\"textin\"\r\n"
"\r\n"
"text\r\n"
multipart_body =
"--multipart-form-data-boundary--see-RFC-2388\r\n"
"Content-Disposition: form-data; "
- "custom1name=\"1\"; "
- "custom2name=\"2\"; "
- "custom3name=\"3\"; "
- "custom4name=\"4\"; "
- "name=\"textin\"\r\n"
+ "custom1name=\"1\"; "
+ "custom2name=\"2\"; "
+ "custom3name=\"3\"; "
+ "custom4name=\"4\"; "
+ "name=\"textin\"\r\n"
"\r\n"
"text\r\n"
"--multipart-form-data-boundary--see-RFC-2388\t\t\t\r\n"
mg_close_connection(client_conn);
/* Handle form: "POST multipart/form-data" very long preamble */
- multipart_body =
- "preamblepreamblepreamblepreamblepreamble\r\n"
- "preamblepreamblepreamblepreamblepreamble\r\n"
- "preamblepreamblepreamblepreamblepreamble\r\n"
- "preamblepreamblepreamblepreamblepreamble\r\n"
- "preamblepreamblepreamblepreamblepreamble\r\n"
- "preamblepreamblepreamblepreamblepreamble\r\n"
- "preamblepreamblepreamblepreamblepreamble\r\n"
- "preamblepreamblepreamblepreamblepreamble\r\n"
- "preamblepreamblepreamblepreamblepreamble\r\n"
- "preamblepreamblepreamblepreamblepreamble\r\n"
- "preamblepreamblepreamblepreamblepreamble\r\n"
- "preamblepreamblepreamblepreamblepreamble\r\n"
- "preamblepreamblepreamblepreamblepreamble\r\n"
- "preamblepreamblepreamblepreamblepreamble\r\n"
- "preamblepreamblepreamblepreamblepreamble\r\n"
- "preamblepreamblepreamblepreamblepreamble\r\n"
- "preamblepreamblepreamblepreamblepreamble\r\n"
- "preamblepreamblepreamblepreamblepreamble\r\n"
- "preamblepreamblepreamblepreamblepreamble\r\n"
- "preamblepreamblepreamblepreamblepreamble\r\n"
- "preamblepreamblepreamblepreamblepreamble\r\n"
- "preamblepreamblepreamblepreamblepreamble\r\n"
- "preamblepreamblepreamblepreamblepreamble\r\n"
- "preamblepreamblepreamblepreamblepreamble\r\n"
- "preamblepreamblepreamblepreamblepreamble\r\n"
- "preamblepreamblepreamblepreamblepreamble\r\n"
- "preamblepreamblepreamblepreamblepreamble\r\n"
- "preamblepreamblepreamblepreamblepreamble\r\n"
- "preamblepreamblepreamblepreamblepreamble\r\n"
- "preamblepreamblepreamblepreamblepreamble\r\n"
- "preamblepreamblepreamblepreamblepreamble\r\n"
- "preamblepreamblepreamblepreamblepreamble\r\n"
- "preamblepreamblepreamblepreamblepreamble\r\n"
- "preamblepreamblepreamblepreamblepreamble\r\n"
- "preamblepreamblepreamblepreamblepreamble\r\n"
- "preamblepreamblepreamblepreamblepreamble\r\n"
- "preamblepreamblepreamblepreamblepreamble\r\n"
- "preamblepreamblepreamblepreamblepreamble\r\n"
- "preamblepreamblepreamblepreamblepreamble\r\n"
- "preamblepreamblepreamblepreamblepreamble\r\n"
- "preamblepreamblepreamblepreamblepreamble\r\n"
- "--multipart-form-data-boundary--see-RFC-2388\r\n";
- "Content-Disposition: form-data; name=\"passwordin\"\r\n"
- "\r\n"
- "\r\n"
- "--multipart-form-data-boundary--see-RFC-2388--\r\n";
+ multipart_body = "preamblepreamblepreamblepreamblepreamble\r\n"
+ "preamblepreamblepreamblepreamblepreamble\r\n"
+ "preamblepreamblepreamblepreamblepreamble\r\n"
+ "preamblepreamblepreamblepreamblepreamble\r\n"
+ "preamblepreamblepreamblepreamblepreamble\r\n"
+ "preamblepreamblepreamblepreamblepreamble\r\n"
+ "preamblepreamblepreamblepreamblepreamble\r\n"
+ "preamblepreamblepreamblepreamblepreamble\r\n"
+ "preamblepreamblepreamblepreamblepreamble\r\n"
+ "preamblepreamblepreamblepreamblepreamble\r\n"
+ "preamblepreamblepreamblepreamblepreamble\r\n"
+ "preamblepreamblepreamblepreamblepreamble\r\n"
+ "preamblepreamblepreamblepreamblepreamble\r\n"
+ "preamblepreamblepreamblepreamblepreamble\r\n"
+ "preamblepreamblepreamblepreamblepreamble\r\n"
+ "preamblepreamblepreamblepreamblepreamble\r\n"
+ "preamblepreamblepreamblepreamblepreamble\r\n"
+ "preamblepreamblepreamblepreamblepreamble\r\n"
+ "preamblepreamblepreamblepreamblepreamble\r\n"
+ "preamblepreamblepreamblepreamblepreamble\r\n"
+ "preamblepreamblepreamblepreamblepreamble\r\n"
+ "preamblepreamblepreamblepreamblepreamble\r\n"
+ "preamblepreamblepreamblepreamblepreamble\r\n"
+ "preamblepreamblepreamblepreamblepreamble\r\n"
+ "preamblepreamblepreamblepreamblepreamble\r\n"
+ "preamblepreamblepreamblepreamblepreamble\r\n"
+ "preamblepreamblepreamblepreamblepreamble\r\n"
+ "preamblepreamblepreamblepreamblepreamble\r\n"
+ "preamblepreamblepreamblepreamblepreamble\r\n"
+ "preamblepreamblepreamblepreamblepreamble\r\n"
+ "preamblepreamblepreamblepreamblepreamble\r\n"
+ "preamblepreamblepreamblepreamblepreamble\r\n"
+ "preamblepreamblepreamblepreamblepreamble\r\n"
+ "preamblepreamblepreamblepreamblepreamble\r\n"
+ "preamblepreamblepreamblepreamblepreamble\r\n"
+ "preamblepreamblepreamblepreamblepreamble\r\n"
+ "preamblepreamblepreamblepreamblepreamble\r\n"
+ "preamblepreamblepreamblepreamblepreamble\r\n"
+ "preamblepreamblepreamblepreamblepreamble\r\n"
+ "preamblepreamblepreamblepreamblepreamble\r\n"
+ "preamblepreamblepreamblepreamblepreamble\r\n"
+ "--multipart-form-data-boundary--see-RFC-2388\r\n";
+ "Content-Disposition: form-data; name=\"passwordin\"\r\n"
+ "\r\n"
+ "\r\n"
+ "--multipart-form-data-boundary--see-RFC-2388--\r\n";
body_len = strlen(multipart_body);
ck_assert_uint_eq(body_len, 1768); /* not required */