gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[libmicrohttpd] branch master updated (f50b6be7 -> 83fe7b77)


From: gnunet
Subject: [libmicrohttpd] branch master updated (f50b6be7 -> 83fe7b77)
Date: Sat, 14 May 2022 15:11:35 +0200

This is an automated email from the git hooks/post-receive script.

karlson2k pushed a change to branch master
in repository libmicrohttpd.

    from f50b6be7 libmicrohttpd.texi: fixed formatting in 
15ea1533a8bb7c9d8eafb25defe4aeba6fa3f7f2
     new a13647d1 Replaced MHD_RESPMEM_MUST_FREE with more portable solution in 
examples
     new 4fc1bbfd MHD_create_response_from_buffer_copy(): fixed doxy
     new 85ae6578 Replaced MHD_RESPMEM_PERSISTENT usage in examples and code
     new 57f3e098 Return NULL for MHD_CONNECTION_INFO_CLIENT_ADDRESS if 
information is not available
     new 1d4a968e Fixed return type for get_system_fdsetsize_value ()
     new 840bc6ec Fixed handling of connections with non-standard client 
addresses (pipe or UNIX sockets).
     new e4d6c07b Fixed some compiler warnings on W32
     new 83fe7b77 Fixed additional compiler warnings on W32

The 8 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 doc/examples/sessions.c                       | 32 +++++----
 doc/examples/tlsauthentication.c              |  3 +-
 doc/examples/websocket.c                      | 25 +++----
 src/examples/connection_close.c               |  5 +-
 src/examples/demo.c                           |  7 +-
 src/examples/demo_https.c                     |  7 +-
 src/examples/http_compression.c               |  8 ++-
 src/examples/minimal_example_empty.c          |  4 +-
 src/examples/minimal_example_empty_tls.c      |  4 +-
 src/examples/post_example.c                   | 14 ++--
 src/examples/querystring_example.c            |  6 +-
 src/examples/websocket_chatserver_example.c   | 22 +++----
 src/include/microhttpd.h                      | 14 ++--
 src/microhttpd/connection.c                   | 16 +++--
 src/microhttpd/daemon.c                       | 94 +++++++++++++++------------
 src/microhttpd/mhd_send.c                     |  6 +-
 src/microhttpd/mhd_sockets.h                  |  4 +-
 src/microhttpd/mhd_threads.c                  |  2 +-
 src/microhttpd/response.c                     | 20 +++---
 src/microhttpd/sysfdsetsize.c                 |  2 +-
 src/microhttpd/sysfdsetsize.h                 |  2 +-
 src/microhttpd/test_response_entries.c        |  2 +-
 src/testcurl/https/test_empty_response.c      |  3 +-
 src/testcurl/https/test_https_get.c           |  4 +-
 src/testcurl/https/test_https_session_info.c  |  5 +-
 src/testcurl/https/tls_test_common.c          |  5 +-
 src/testcurl/test_digestauth.c                | 15 ++---
 src/testcurl/test_digestauth_concurrent.c     | 15 ++---
 src/testcurl/test_digestauth_sha256.c         | 15 ++---
 src/testcurl/test_digestauth_with_arguments.c | 14 ++--
 src/testcurl/test_get.c                       |  4 +-
 src/testcurl/test_get_chunked.c               |  3 +-
 src/testcurl/test_get_empty.c                 |  8 +--
 src/testcurl/test_post.c                      |  3 +-
 src/testcurl/test_post_loop.c                 |  4 +-
 src/testcurl/test_termination.c               |  3 +-
 36 files changed, 200 insertions(+), 200 deletions(-)

diff --git a/doc/examples/sessions.c b/doc/examples/sessions.c
index 9b36c485..121cf2e0 100644
--- a/doc/examples/sessions.c
+++ b/doc/examples/sessions.c
@@ -347,19 +347,22 @@ fill_v1_form (const void *cls,
   enum MHD_Result ret;
   char *reply;
   struct MHD_Response *response;
+  int reply_len;
   (void) cls; /* Unused */
 
-  if (-1 == MHD_asprintf (&reply,
-                          MAIN_PAGE,
-                          session->value_1))
+  reply_len = MHD_asprintf (&reply,
+                            MAIN_PAGE,
+                            session->value_1);
+  if (0 > reply_len)
   {
     /* oops */
     return MHD_NO;
   }
   /* return static form */
-  response = MHD_create_response_from_buffer (strlen (reply),
-                                              (void *) reply,
-                                              MHD_RESPMEM_MUST_FREE);
+  response =
+    MHD_create_response_from_buffer_with_free_callback ((size_t) reply_len,
+                                                        (void *) reply,
+                                                        &free);
   add_session_cookie (session, response);
   MHD_add_response_header (response,
                            MHD_HTTP_HEADER_CONTENT_ENCODING,
@@ -389,20 +392,23 @@ fill_v1_v2_form (const void *cls,
   enum MHD_Result ret;
   char *reply;
   struct MHD_Response *response;
+  int reply_len;
   (void) cls; /* Unused */
 
-  if (-1 == MHD_asprintf (&reply,
-                          SECOND_PAGE,
-                          session->value_1,
-                          session->value_2))
+  reply_len = MHD_asprintf (&reply,
+                            SECOND_PAGE,
+                            session->value_1,
+                            session->value_2);
+  if (0 > reply_len)
   {
     /* oops */
     return MHD_NO;
   }
   /* return static form */
-  response = MHD_create_response_from_buffer (strlen (reply),
-                                              (void *) reply,
-                                              MHD_RESPMEM_MUST_FREE);
+  response =
+    MHD_create_response_from_buffer_with_free_callback (reply_len,
+                                                        (void *) reply,
+                                                        &free);
   add_session_cookie (session, response);
   MHD_add_response_header (response,
                            MHD_HTTP_HEADER_CONTENT_ENCODING,
diff --git a/doc/examples/tlsauthentication.c b/doc/examples/tlsauthentication.c
index 3c39a0f5..57556d0b 100644
--- a/doc/examples/tlsauthentication.c
+++ b/doc/examples/tlsauthentication.c
@@ -130,8 +130,7 @@ ask_for_authentication (struct MHD_Connection *connection, 
const char *realm)
   size_t slen;
   const char *strbase = "Basic realm=";
 
-  response = MHD_create_response_from_buffer (0, NULL,
-                                              MHD_RESPMEM_PERSISTENT);
+  response = MHD_create_response_empty (MHD_RF_NONE);
   if (! response)
     return MHD_NO;
 
diff --git a/doc/examples/websocket.c b/doc/examples/websocket.c
index 77bc55cd..018d4c5a 100644
--- a/doc/examples/websocket.c
+++ b/doc/examples/websocket.c
@@ -330,10 +330,9 @@ access_handler (void *cls,
   if (0 == strcmp (url, "/"))
   {
     /* Default page for visiting the server */
-    struct MHD_Response *response = MHD_create_response_from_buffer (
-      strlen (PAGE),
-      PAGE,
-      MHD_RESPMEM_PERSISTENT);
+    struct MHD_Response *response;
+    response = MHD_create_response_from_buffer_static (strlen (PAGE),
+                                                       PAGE);
     ret = MHD_queue_response (connection,
                               MHD_HTTP_OK,
                               response);
@@ -400,10 +399,11 @@ access_handler (void *cls,
     else
     {
       /* return error page */
-      struct MHD_Response *response = MHD_create_response_from_buffer (
-        strlen (PAGE_INVALID_WEBSOCKET_REQUEST),
-        PAGE_INVALID_WEBSOCKET_REQUEST,
-        MHD_RESPMEM_PERSISTENT);
+      struct MHD_Response *response;
+      response =
+        MHD_create_response_from_buffer_static (strlen (
+                                                  
PAGE_INVALID_WEBSOCKET_REQUEST),
+                                                
PAGE_INVALID_WEBSOCKET_REQUEST);
       ret = MHD_queue_response (connection,
                                 MHD_HTTP_BAD_REQUEST,
                                 response);
@@ -412,10 +412,11 @@ access_handler (void *cls,
   }
   else
   {
-    struct MHD_Response *response = MHD_create_response_from_buffer (
-      strlen (PAGE_NOT_FOUND),
-      PAGE_NOT_FOUND,
-      MHD_RESPMEM_PERSISTENT);
+    struct MHD_Response *response;
+    response =
+      MHD_create_response_from_buffer_static (strlen (
+                                                PAGE_NOT_FOUND),
+                                              PAGE_NOT_FOUND);
     ret = MHD_queue_response (connection,
                               MHD_HTTP_NOT_FOUND,
                               response);
diff --git a/src/examples/connection_close.c b/src/examples/connection_close.c
index e5f787a3..8558eb46 100644
--- a/src/examples/connection_close.c
+++ b/src/examples/connection_close.c
@@ -61,9 +61,8 @@ ahc_echo (void *cls,
     return MHD_YES;
   }
   *req_cls = NULL;                  /* reset when done */
-  response = MHD_create_response_from_buffer (strlen (me),
-                                              (void *) me,
-                                              MHD_RESPMEM_PERSISTENT);
+  response = MHD_create_response_from_buffer_static (strlen (me),
+                                                     me);
   ret = MHD_queue_response (connection, MHD_HTTP_OK, response);
   MHD_destroy_response (response);
   return ret;
diff --git a/src/examples/demo.c b/src/examples/demo.c
index 1c24a57e..9aef573a 100644
--- a/src/examples/demo.c
+++ b/src/examples/demo.c
@@ -383,9 +383,10 @@ update_directory (void)
                        "%s",
                        INDEX_PAGE_FOOTER);
   initial_allocation = rdc.buf_len; /* remember for next time */
-  response = MHD_create_response_from_buffer (rdc.off,
-                                              rdc.buf,
-                                              MHD_RESPMEM_MUST_FREE);
+  response =
+    MHD_create_response_from_buffer_with_free_callback (rdc.off,
+                                                        rdc.buf,
+                                                        &free);
   mark_as_html (response);
 #if FORCE_CLOSE
   (void) MHD_add_response_header (response,
diff --git a/src/examples/demo_https.c b/src/examples/demo_https.c
index 1a09d2c2..56008d7f 100644
--- a/src/examples/demo_https.c
+++ b/src/examples/demo_https.c
@@ -385,9 +385,10 @@ update_directory (void)
                        "%s",
                        INDEX_PAGE_FOOTER);
   initial_allocation = rdc.buf_len; /* remember for next time */
-  response = MHD_create_response_from_buffer (rdc.off,
-                                              rdc.buf,
-                                              MHD_RESPMEM_MUST_FREE);
+  response =
+    MHD_create_response_from_buffer_with_free_callback (rdc.off,
+                                                        rdc.buf,
+                                                        &free);
   mark_as_html (response);
 #if FORCE_CLOSE
   (void) MHD_add_response_header (response,
diff --git a/src/examples/http_compression.c b/src/examples/http_compression.c
index a91a39a3..0f532cf0 100644
--- a/src/examples/http_compression.c
+++ b/src/examples/http_compression.c
@@ -130,9 +130,11 @@ ahc_echo (void *cls,
       can_compress (connection))
     comp = body_compress ((void **) &body_str,
                           &body_len);
-  response = MHD_create_response_from_buffer (body_len,
-                                              body_str,
-                                              MHD_RESPMEM_MUST_FREE);
+  response =
+    MHD_create_response_from_buffer_with_free_callback (body_len,
+                                                        body_str,
+                                                        &free);
+
   if (NULL == response)
   {
     free (body_str);
diff --git a/src/examples/minimal_example_empty.c 
b/src/examples/minimal_example_empty.c
index 43719a24..84837f08 100644
--- a/src/examples/minimal_example_empty.c
+++ b/src/examples/minimal_example_empty.c
@@ -55,9 +55,7 @@ ahc_echo (void *cls,
     return MHD_YES;
   }
   *req_cls = NULL;                  /* reset when done */
-  response = MHD_create_response_from_buffer (0,
-                                              NULL,
-                                              MHD_RESPMEM_PERSISTENT);
+  response = MHD_create_response_empty (MHD_RF_NONE);
   ret = MHD_queue_response (connection,
                             MHD_HTTP_NO_CONTENT,
                             response);
diff --git a/src/examples/minimal_example_empty_tls.c 
b/src/examples/minimal_example_empty_tls.c
index 9c352717..c8c3763f 100644
--- a/src/examples/minimal_example_empty_tls.c
+++ b/src/examples/minimal_example_empty_tls.c
@@ -55,9 +55,7 @@ ahc_echo (void *cls,
     return MHD_YES;
   }
   *req_cls = NULL;                  /* reset when done */
-  response = MHD_create_response_from_buffer (0,
-                                              NULL,
-                                              MHD_RESPMEM_PERSISTENT);
+  response = MHD_create_response_empty (MHD_RF_NONE);
   ret = MHD_queue_response (connection,
                             MHD_HTTP_NO_CONTENT,
                             response);
diff --git a/src/examples/post_example.c b/src/examples/post_example.c
index 709fc918..1b6a5a03 100644
--- a/src/examples/post_example.c
+++ b/src/examples/post_example.c
@@ -332,9 +332,10 @@ fill_v1_form (const void *cls,
             MAIN_PAGE,
             session->value_1);
   /* return static form */
-  response = MHD_create_response_from_buffer (slen,
-                                              (void *) reply,
-                                              MHD_RESPMEM_MUST_FREE);
+  response =
+    MHD_create_response_from_buffer_with_free_callback (slen,
+                                                        (void *) reply,
+                                                        &free);
   if (NULL == response)
   {
     free (reply);
@@ -383,9 +384,10 @@ fill_v1_v2_form (const void *cls,
             session->value_1,
             session->value_2);
   /* return static form */
-  response = MHD_create_response_from_buffer (slen,
-                                              (void *) reply,
-                                              MHD_RESPMEM_MUST_FREE);
+  response =
+    MHD_create_response_from_buffer_with_free_callback (slen,
+                                                        (void *) reply,
+                                                        &free);
   if (NULL == response)
   {
     free (reply);
diff --git a/src/examples/querystring_example.c 
b/src/examples/querystring_example.c
index 57de5aa7..97a92ae2 100644
--- a/src/examples/querystring_example.c
+++ b/src/examples/querystring_example.c
@@ -72,8 +72,10 @@ ahc_echo (void *cls,
     free (me);
     return MHD_NO;  /* Error forming the response body */
   }
-  response = MHD_create_response_from_buffer (resp_len, me,
-                                              MHD_RESPMEM_MUST_FREE);
+  response =
+    MHD_create_response_from_buffer_with_free_callback (resp_len,
+                                                        (void *) me,
+                                                        &free);
   if (response == NULL)
   {
     free (me);
diff --git a/src/examples/websocket_chatserver_example.c 
b/src/examples/websocket_chatserver_example.c
index 052b4221..cc3005a2 100644
--- a/src/examples/websocket_chatserver_example.c
+++ b/src/examples/websocket_chatserver_example.c
@@ -2163,10 +2163,9 @@ access_handler (void *cls,
   if (0 == strcmp (url, "/"))
   {
     /* Default page for visiting the server */
-    struct MHD_Response *response = MHD_create_response_from_buffer (strlen (
-                                                                       PAGE),
-                                                                     PAGE,
-                                                                     
MHD_RESPMEM_PERSISTENT);
+    struct MHD_Response *response;
+    response = MHD_create_response_from_buffer_static (strlen (PAGE),
+                                                       PAGE);
     ret = MHD_queue_response (connection,
                               MHD_HTTP_OK,
                               response);
@@ -2259,10 +2258,10 @@ access_handler (void *cls,
     else
     {
       /* return error page */
-      struct MHD_Response *response = MHD_create_response_from_buffer (strlen (
-                                                                         
PAGE_INVALID_WEBSOCKET_REQUEST),
-                                                                       
PAGE_INVALID_WEBSOCKET_REQUEST,
-                                                                       
MHD_RESPMEM_PERSISTENT);
+      struct MHD_Response *response;
+      response = MHD_create_response_from_buffer_static (strlen (
+                                                           
PAGE_INVALID_WEBSOCKET_REQUEST),
+                                                         
PAGE_INVALID_WEBSOCKET_REQUEST);
       ret = MHD_queue_response (connection,
                                 MHD_HTTP_BAD_REQUEST,
                                 response);
@@ -2271,10 +2270,9 @@ access_handler (void *cls,
   }
   else
   {
-    struct MHD_Response *response = MHD_create_response_from_buffer (strlen (
-                                                                       
PAGE_NOT_FOUND),
-                                                                     
PAGE_NOT_FOUND,
-                                                                     
MHD_RESPMEM_PERSISTENT);
+    struct MHD_Response *response;
+    response = MHD_create_response_from_buffer_static (strlen (PAGE_NOT_FOUND),
+                                                       PAGE_NOT_FOUND);
     ret = MHD_queue_response (connection,
                               MHD_HTTP_NOT_FOUND,
                               response);
diff --git a/src/include/microhttpd.h b/src/include/microhttpd.h
index 921ab56b..3e1dbc96 100644
--- a/src/include/microhttpd.h
+++ b/src/include/microhttpd.h
@@ -3624,10 +3624,12 @@ enum MHD_ResponseMemoryMode
    * Buffer is heap-allocated with `malloc()` (or equivalent) and
    * should be freed by MHD after processing the response has
    * concluded (response reference counter reaches zero).
-   * @warning Make sure that your application and MHD are using the same
-   *          C-runtime library (especially important for W32). if in doubt,
-   *          use function MHD_create_response_from_buffer_with_free_callback()
-   *          with '&free' as crfc parameter.
+   * The more portable way to automatically free the buffer is function
+   * MHD_create_response_from_buffer_with_free_callback() with '&free' as
+   * crfc parameter as it does not require to use the same runtime library.
+   * @warning It is critical to make sure that the same C-runtime library
+   *          is used by both application and MHD (especially
+   *          important for W32).
    * @ingroup response
    */
   MHD_RESPMEM_MUST_FREE,
@@ -3694,8 +3696,8 @@ MHD_create_response_from_buffer_static (size_t size,
 
 
 /**
- * Create a response object with the content of provided statically allocated
- * buffer used as the response body.
+ * Create a response object with the content of provided temporal buffer
+ * used as the response body.
  *
  * An internal copy of the buffer will be made automatically, so buffer have
  * to be valid only during the call of this function (as a typical example:
diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c
index ab659064..949e6ec4 100644
--- a/src/microhttpd/connection.c
+++ b/src/microhttpd/connection.c
@@ -5041,12 +5041,16 @@ MHD_get_connection_info (struct MHD_Connection 
*connection,
     return &connection->connection_info_dummy;
 #endif /* HTTPS_SUPPORT */
   case MHD_CONNECTION_INFO_CLIENT_ADDRESS:
-    memset (&connection->connection_info_dummy.client_addr, 0,
-            sizeof (connection->connection_info_dummy.client_addr));
-    memcpy (&connection->connection_info_dummy.client_addr,
-            &connection->addr,
-            connection->addr_len);
-    return &connection->connection_info_dummy;
+    if (0 < connection->addr_len)
+    {
+      memset (&connection->connection_info_dummy.client_addr, 0,
+              sizeof (connection->connection_info_dummy.client_addr));
+      memcpy (&connection->connection_info_dummy.client_addr,
+              &connection->addr,
+              (size_t) connection->addr_len);
+      return &connection->connection_info_dummy;
+    }
+    return NULL;
   case MHD_CONNECTION_INFO_DAEMON:
     connection->connection_info_dummy.daemon = connection->daemon;
     return &connection->connection_info_dummy;
diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c
index b7980460..e96ef4a2 100644
--- a/src/microhttpd/daemon.c
+++ b/src/microhttpd/daemon.c
@@ -319,38 +319,37 @@ MHD_ip_addr_to_key (const struct sockaddr *addr,
                     socklen_t addrlen,
                     struct MHD_IPCount *key)
 {
-#ifndef DEBUG
-  (void) addrlen; /* Mute compiler warning */
-#endif /* DEBUG */
   memset (key,
           0,
           sizeof(*key));
 
   /* IPv4 addresses */
-  if (AF_INET == addr->sa_family)
+  if (sizeof (struct sockaddr_in) <= (size_t) addrlen)
   {
-    mhd_assert (sizeof (struct sockaddr_in) <= (size_t) addrlen);
-
-    key->family = AF_INET;
-    memcpy (&key->addr.ipv4,
-            ((const uint8_t *) addr)
-            + _MHD_OFFSETOF (struct sockaddr_in, sin_addr),
-            sizeof(((struct sockaddr_in *) NULL)->sin_addr));
-    return MHD_YES;
+    if (AF_INET == addr->sa_family)
+    {
+      key->family = AF_INET;
+      memcpy (&key->addr.ipv4,
+              ((const uint8_t *) addr)
+              + _MHD_OFFSETOF (struct sockaddr_in, sin_addr),
+              sizeof(((struct sockaddr_in *) NULL)->sin_addr));
+      return MHD_YES;
+    }
   }
 
 #if HAVE_INET6
-  /* IPv6 addresses */
-  if (AF_INET6 == addr->sa_family)
+  if (sizeof (struct sockaddr_in6) <= (size_t) addrlen)
   {
-    mhd_assert (sizeof (struct sockaddr_in6) <= (size_t) addrlen);
-
-    key->family = AF_INET6;
-    memcpy (&key->addr.ipv6,
-            ((const uint8_t *) addr)
-            + _MHD_OFFSETOF (struct sockaddr_in6, sin6_addr),
-            sizeof(((struct sockaddr_in6 *) NULL)->sin6_addr));
-    return MHD_YES;
+    /* IPv6 addresses */
+    if (AF_INET6 == addr->sa_family)
+    {
+      key->family = AF_INET6;
+      memcpy (&key->addr.ipv6,
+              ((const uint8_t *) addr)
+              + _MHD_OFFSETOF (struct sockaddr_in6, sin6_addr),
+              sizeof(((struct sockaddr_in6 *) NULL)->sin6_addr));
+      return MHD_YES;
+    }
   }
 #endif
 
@@ -1885,7 +1884,7 @@ thread_main_handle_connection (void *data)
   MHD_socket maxsock;
 #if WINDOWS
 #ifdef HAVE_POLL
-  int extra_slot;
+  unsigned int extra_slot;
 #endif /* HAVE_POLL */
 #define EXTRA_SLOTS 1
 #else  /* !WINDOWS */
@@ -2498,25 +2497,30 @@ new_connection_prepare_ (struct MHD_Daemon *daemon,
     connection->sk_nodelay = _MHD_UNKNOWN;
   }
 
-  if (NULL == (connection->addr = malloc (addrlen)))
+  if (0 < addrlen)
   {
-    eno = errno;
+    if (NULL == (connection->addr = malloc ((size_t) addrlen)))
+    {
+      eno = errno;
 #ifdef HAVE_MESSAGES
-    MHD_DLOG (daemon,
-              _ ("Error allocating memory: %s\n"),
-              MHD_strerror_ (errno));
+      MHD_DLOG (daemon,
+                _ ("Error allocating memory: %s\n"),
+                MHD_strerror_ (errno));
 #endif
-    MHD_socket_close_chk_ (client_socket);
-    MHD_ip_limit_del (daemon,
-                      addr,
-                      addrlen);
-    free (connection);
-    errno = eno;
-    return NULL;
+      MHD_socket_close_chk_ (client_socket);
+      MHD_ip_limit_del (daemon,
+                        addr,
+                        addrlen);
+      free (connection);
+      errno = eno;
+      return NULL;
+    }
+    memcpy (connection->addr,
+            addr,
+            (size_t) addrlen);
   }
-  memcpy (connection->addr,
-          addr,
-          addrlen);
+  else
+    connection->addr = NULL;
   connection->addr_len = addrlen;
   connection->socket_fd = client_socket;
   connection->sk_nonblck = non_blck;
@@ -2569,7 +2573,8 @@ new_connection_prepare_ (struct MHD_Daemon *daemon,
       MHD_ip_limit_del (daemon,
                         addr,
                         addrlen);
-      free (connection->addr);
+      if (NULL != connection->addr)
+        free (connection->addr);
       free (connection);
 #ifdef HAVE_MESSAGES
       MHD_DLOG (daemon,
@@ -2633,7 +2638,8 @@ new_connection_prepare_ (struct MHD_Daemon *daemon,
       MHD_ip_limit_del (daemon,
                         addr,
                         addrlen);
-      free (connection->addr);
+      if (NULL != connection->addr)
+        free (connection->addr);
       free (connection);
       MHD_PANIC (_ ("Unknown credential type.\n"));
 #if EINVAL
@@ -2701,7 +2707,8 @@ new_connection_close_ (struct MHD_Daemon *daemon,
   MHD_ip_limit_del (daemon,
                     connection->addr,
                     connection->addr_len);
-  free (connection->addr);
+  if (NULL != connection->addr)
+    free (connection->addr);
   free (connection);
 }
 
@@ -2896,7 +2903,8 @@ new_connection_process_ (struct MHD_Daemon *daemon,
   MHD_ip_limit_del (daemon,
                     connection->addr,
                     connection->addr_len);
-  free (connection->addr);
+  if (NULL != connection->addr)
+    free (connection->addr);
   MHD_socket_close_chk_ (connection->socket_fd);
   free (connection);
   if (0 != eno)
@@ -7003,7 +7011,7 @@ MHD_start_daemon_va (unsigned int flags,
 #else  /* SO_EXCLBIND */
                           SO_EXCLBIND,
 #endif /* SO_EXCLBIND */
-                          (void *) &on,
+                          (const void *) &on,
                           sizeof (on)))
       {
 #ifdef HAVE_MESSAGES
diff --git a/src/microhttpd/mhd_send.c b/src/microhttpd/mhd_send.c
index c607a4c8..be471619 100644
--- a/src/microhttpd/mhd_send.c
+++ b/src/microhttpd/mhd_send.c
@@ -1081,9 +1081,9 @@ MHD_send_hdr_and_body_ (struct MHD_Connection *connection,
     complete_response = false;
     push_body = complete_response;
   }
-  vector[0].buf = (char *) header;
+  vector[0].buf = (char *) _MHD_DROP_CONST (header);
   vector[0].len = (unsigned long) header_size;
-  vector[1].buf = (char *) body;
+  vector[1].buf = (char *) _MHD_DROP_CONST (body);
   vector[1].len = (unsigned long) body_size;
 
   ret = WSASend (s, vector, 2, &vec_sent, 0, NULL, NULL);
@@ -1600,7 +1600,7 @@ send_iov_emu (struct MHD_Connection *connection,
        * Adjust buffer of the last element. */
       r_iov->iov[r_iov->sent].iov_base =
         (void *) ((uint8_t *) r_iov->iov[r_iov->sent].iov_base + sent);
-      r_iov->iov[r_iov->sent].iov_len -= sent;
+      r_iov->iov[r_iov->sent].iov_len -= (MHD_iov_size_) sent;
 
       return (ssize_t) total_sent;
     }
diff --git a/src/microhttpd/mhd_sockets.h b/src/microhttpd/mhd_sockets.h
index 89f7d161..224d8464 100644
--- a/src/microhttpd/mhd_sockets.h
+++ b/src/microhttpd/mhd_sockets.h
@@ -443,8 +443,8 @@ typedef int MHD_SCKT_SEND_SIZE_;
       (((void*) (w) == (void*) 0) || ((fd_set*) (w))->fd_count == 0) &&  \
       (((void*) (e) == (void*) 0) || ((fd_set*) (e))->fd_count == 0) ) ? \
     ( ((void*) (t) == (void*) 0) ? 0 :                                   \
-      (Sleep (((struct timeval*) (t))->tv_sec * 1000                     \
-              + ((struct timeval*) (t))->tv_usec / 1000), 0) ) :         \
+      (Sleep ((DWORD)((struct timeval*) (t))->tv_sec * 1000              \
+              + (DWORD)((struct timeval*) (t))->tv_usec / 1000), 0) ) :  \
     (select ((int) 0,(r),(w),(e),(t))) )
 #endif
 
diff --git a/src/microhttpd/mhd_threads.c b/src/microhttpd/mhd_threads.c
index 45a10f12..628a628f 100644
--- a/src/microhttpd/mhd_threads.c
+++ b/src/microhttpd/mhd_threads.c
@@ -225,7 +225,7 @@ MHD_create_thread_ (MHD_thread_handle_ID_ *thread,
   }
 #endif /* SIZEOF_SIZE_T != SIZEOF_UNSIGNED_INT */
 
-  thread->handle = (MHD_thread_handle_)
+  thread->handle = (MHD_thread_handle_) (uintptr_t)
                    _beginthreadex (NULL,
                                    (unsigned int) stack_size,
                                    start_routine,
diff --git a/src/microhttpd/response.c b/src/microhttpd/response.c
index 65158819..4c6c192a 100644
--- a/src/microhttpd/response.c
+++ b/src/microhttpd/response.c
@@ -967,7 +967,7 @@ file_reader (void *cls,
 #if ! defined(_WIN32) || defined(__CYGWIN__)
   ssize_t n;
 #else  /* _WIN32 && !__CYGWIN__ */
-  const HANDLE fh = (HANDLE) _get_osfhandle (response->fd);
+  const HANDLE fh = (HANDLE) (uintptr_t) _get_osfhandle (response->fd);
 #endif /* _WIN32 && !__CYGWIN__ */
   const int64_t offset64 = (int64_t) (pos + response->fd_off);
 
@@ -1055,17 +1055,21 @@ pipe_reader (void *cls,
   ssize_t n;
 
   (void) pos;
+
 #ifndef _WIN32
   if (SSIZE_MAX < max)
     max = SSIZE_MAX;
+  n = read (response->fd,
+            buf,
+            (MHD_SCKT_SEND_SIZE_) max);
 #else  /* _WIN32 */
   if (UINT_MAX < max)
-    max = UINT_MAX;
-#endif /* _WIN32 */
-
+    max = INT_MAX;
   n = read (response->fd,
             buf,
-            (MHD_SCKT_SEND_SIZE_) max);
+            (unsigned int) max);
+#endif /* _WIN32 */
+
   if (0 == n)
     return MHD_CONTENT_READER_END_OF_STREAM;
   if (n < 0)
@@ -1386,8 +1390,8 @@ MHD_create_response_from_buffer_static (size_t size,
 
 
 /**
- * Create a response object with the content of provided statically allocated
- * buffer used as the response body.
+ * Create a response object with the content of provided temporal buffer
+ * used as the response body.
  *
  * An internal copy of the buffer will be made automatically, so buffer have
  * to be valid only during the call of this function (as a typical example:
@@ -1595,7 +1599,7 @@ MHD_create_response_from_iovec (const struct MHD_IoVec 
*iov,
     {
       int64_t i_add;
 
-      i_add = iov[i].iov_len / ULONG_MAX;
+      i_add = (int64_t) (iov[i].iov_len / ULONG_MAX);
       if (0 != iov[i].iov_len % ULONG_MAX)
         i_add++;
       if (INT_MAX < (i_add + i_cp))
diff --git a/src/microhttpd/sysfdsetsize.c b/src/microhttpd/sysfdsetsize.c
index 8268e274..150d4a59 100644
--- a/src/microhttpd/sysfdsetsize.c
+++ b/src/microhttpd/sysfdsetsize.c
@@ -75,7 +75,7 @@
  * Get system default value of FD_SETSIZE
  * @return system default value of FD_SETSIZE
  */
-int
+unsigned int
 get_system_fdsetsize_value (void)
 {
   return FD_SETSIZE;
diff --git a/src/microhttpd/sysfdsetsize.h b/src/microhttpd/sysfdsetsize.h
index e3585b22..6b0e37d4 100644
--- a/src/microhttpd/sysfdsetsize.h
+++ b/src/microhttpd/sysfdsetsize.h
@@ -30,7 +30,7 @@
  * Get system default value of FD_SETSIZE
  * @return system default value of FD_SETSIZE
  */
-int
+unsigned int
 get_system_fdsetsize_value (void);
 
 #endif /* !SYSFDSETSIZE_H */
diff --git a/src/microhttpd/test_response_entries.c 
b/src/microhttpd/test_response_entries.c
index 5386b8da..7e1b18a8 100644
--- a/src/microhttpd/test_response_entries.c
+++ b/src/microhttpd/test_response_entries.c
@@ -54,7 +54,7 @@ main (int argc,
   (void) argv; /* Unused. Silence compiler warning. */
   struct MHD_Response *r;
 
-  r = MHD_create_response_from_buffer (0, "", MHD_RESPMEM_PERSISTENT);
+  r = MHD_create_response_empty (MHD_RF_NONE);
   if (NULL == r)
   {
     fprintf (stderr, "Cannot create a response.\n");
diff --git a/src/testcurl/https/test_empty_response.c 
b/src/testcurl/https/test_empty_response.c
index f4cce216..b338fa2e 100644
--- a/src/testcurl/https/test_empty_response.c
+++ b/src/testcurl/https/test_empty_response.c
@@ -52,8 +52,7 @@ ahc_echo (void *cls,
   (void) cls; (void) url; (void) method; (void) version;             /* 
Unused. Silent compiler warning. */
   (void) upload_data; (void) upload_data_size; (void) req_cls;       /* 
Unused. Silent compiler warning. */
 
-  response = MHD_create_response_from_buffer (0, NULL,
-                                              MHD_RESPMEM_PERSISTENT);
+  response = MHD_create_response_empty (MHD_RF_NONE);
   ret = MHD_queue_response (connection, MHD_HTTP_OK, response);
   MHD_destroy_response (response);
   return ret;
diff --git a/src/testcurl/https/test_https_get.c 
b/src/testcurl/https/test_https_get.c
index 968a0b96..184cc48e 100644
--- a/src/testcurl/https/test_https_get.c
+++ b/src/testcurl/https/test_https_get.c
@@ -120,9 +120,7 @@ ahc_empty (void *cls,
     return MHD_YES;
   }
   *req_cls = NULL;
-  response = MHD_create_response_from_buffer (0,
-                                              NULL,
-                                              MHD_RESPMEM_PERSISTENT);
+  response = MHD_create_response_empty (MHD_RF_NONE);
   ret = MHD_queue_response (connection,
                             MHD_HTTP_OK,
                             response);
diff --git a/src/testcurl/https/test_https_session_info.c 
b/src/testcurl/https/test_https_session_info.c
index e428e278..b0ccb576 100644
--- a/src/testcurl/https/test_https_session_info.c
+++ b/src/testcurl/https/test_https_session_info.c
@@ -84,9 +84,8 @@ query_session_ahc (void *cls, struct MHD_Connection 
*connection,
     }
   }
 
-  response = MHD_create_response_from_buffer (strlen (EMPTY_PAGE),
-                                              (void *) EMPTY_PAGE,
-                                              MHD_RESPMEM_PERSISTENT);
+  response = MHD_create_response_from_buffer_static (strlen (EMPTY_PAGE),
+                                                     EMPTY_PAGE);
   ret = MHD_queue_response (connection, MHD_HTTP_OK, response);
   MHD_destroy_response (response);
   return ret;
diff --git a/src/testcurl/https/tls_test_common.c 
b/src/testcurl/https/tls_test_common.c
index 8d33e5d4..f3c561fe 100644
--- a/src/testcurl/https/tls_test_common.c
+++ b/src/testcurl/https/tls_test_common.c
@@ -224,9 +224,8 @@ http_ahc (void *cls,
     return MHD_YES;
   }
   *req_cls = NULL;                  /* reset when done */
-  response = MHD_create_response_from_buffer (strlen (test_data),
-                                              (void *) test_data,
-                                              MHD_RESPMEM_PERSISTENT);
+  response = MHD_create_response_from_buffer_static (strlen (test_data),
+                                                     test_data);
   ret = MHD_queue_response (connection, MHD_HTTP_OK, response);
   MHD_destroy_response (response);
   return ret;
diff --git a/src/testcurl/test_digestauth.c b/src/testcurl/test_digestauth.c
index e05e4f31..6f22c1f2 100644
--- a/src/testcurl/test_digestauth.c
+++ b/src/testcurl/test_digestauth.c
@@ -282,9 +282,8 @@ ahc_echo (void *cls,
   if ( (username == NULL) ||
        (0 != strcmp (username, "testuser")) )
   {
-    response = MHD_create_response_from_buffer (strlen (DENIED),
-                                                DENIED,
-                                                MHD_RESPMEM_PERSISTENT);
+    response = MHD_create_response_from_buffer_static (strlen (DENIED),
+                                                       DENIED);
     if (NULL == response)
       mhdErrorExitDesc ("MHD_create_response_from_buffer failed");
     ret = MHD_queue_auth_fail_response2 (connection,
@@ -307,9 +306,8 @@ ahc_echo (void *cls,
   MHD_free (username);
   if (ret_e != MHD_DAUTH_OK)
   {
-    response = MHD_create_response_from_buffer (strlen (DENIED),
-                                                DENIED,
-                                                MHD_RESPMEM_PERSISTENT);
+    response = MHD_create_response_from_buffer_static (strlen (DENIED),
+                                                       DENIED);
     if (NULL == response)
       mhdErrorExitDesc ("MHD_create_response_from_buffer() failed");
     ret = MHD_queue_auth_fail_response2 (connection,
@@ -324,9 +322,8 @@ ahc_echo (void *cls,
     MHD_destroy_response (response);
     return ret;
   }
-  response = MHD_create_response_from_buffer (strlen (PAGE),
-                                              PAGE,
-                                              MHD_RESPMEM_PERSISTENT);
+  response = MHD_create_response_from_buffer_static (strlen (PAGE),
+                                                     PAGE);
   if (NULL == response)
     mhdErrorExitDesc ("MHD_create_response_from_buffer() failed");
   ret = MHD_queue_response (connection,
diff --git a/src/testcurl/test_digestauth_concurrent.c 
b/src/testcurl/test_digestauth_concurrent.c
index 5795c686..045b673d 100644
--- a/src/testcurl/test_digestauth_concurrent.c
+++ b/src/testcurl/test_digestauth_concurrent.c
@@ -293,9 +293,8 @@ ahc_echo (void *cls,
   if ( (username == NULL) ||
        (0 != strcmp (username, "testuser")) )
   {
-    response = MHD_create_response_from_buffer (strlen (DENIED),
-                                                DENIED,
-                                                MHD_RESPMEM_PERSISTENT);
+    response = MHD_create_response_from_buffer_static (strlen (DENIED),
+                                                       DENIED);
     if (NULL == response)
       mhdErrorExitDesc ("MHD_create_response_from_buffer failed");
     ret = MHD_queue_auth_fail_response2 (connection,
@@ -318,9 +317,8 @@ ahc_echo (void *cls,
   MHD_free (username);
   if (ret_e != MHD_DAUTH_OK)
   {
-    response = MHD_create_response_from_buffer (strlen (DENIED),
-                                                DENIED,
-                                                MHD_RESPMEM_PERSISTENT);
+    response = MHD_create_response_from_buffer_static (strlen (DENIED),
+                                                       DENIED);
     if (NULL == response)
       mhdErrorExitDesc ("MHD_create_response_from_buffer() failed");
     ret = MHD_queue_auth_fail_response2 (connection,
@@ -335,9 +333,8 @@ ahc_echo (void *cls,
     MHD_destroy_response (response);
     return ret;
   }
-  response = MHD_create_response_from_buffer (strlen (PAGE),
-                                              PAGE,
-                                              MHD_RESPMEM_PERSISTENT);
+  response = MHD_create_response_from_buffer_static (strlen (PAGE),
+                                                     PAGE);
   if (NULL == response)
     mhdErrorExitDesc ("MHD_create_response_from_buffer() failed");
   ret = MHD_queue_response (connection,
diff --git a/src/testcurl/test_digestauth_sha256.c 
b/src/testcurl/test_digestauth_sha256.c
index bfab4a7e..90e5ad5f 100644
--- a/src/testcurl/test_digestauth_sha256.c
+++ b/src/testcurl/test_digestauth_sha256.c
@@ -111,9 +111,8 @@ ahc_echo (void *cls,
   if ( (username == NULL) ||
        (0 != strcmp (username, "testuser")) )
   {
-    response = MHD_create_response_from_buffer (strlen (DENIED),
-                                                DENIED,
-                                                MHD_RESPMEM_PERSISTENT);
+    response = MHD_create_response_from_buffer_static (strlen (DENIED),
+                                                       DENIED);
     ret = MHD_queue_auth_fail_response2 (connection,
                                          realm,
                                          MY_OPAQUE,
@@ -132,9 +131,8 @@ ahc_echo (void *cls,
   MHD_free (username);
   if (ret_e != MHD_DAUTH_OK)
   {
-    response = MHD_create_response_from_buffer (strlen (DENIED),
-                                                DENIED,
-                                                MHD_RESPMEM_PERSISTENT);
+    response = MHD_create_response_from_buffer_static (strlen (DENIED),
+                                                       DENIED);
     if (NULL == response)
       return MHD_NO;
     ret = MHD_queue_auth_fail_response2 (connection,
@@ -147,9 +145,8 @@ ahc_echo (void *cls,
     MHD_destroy_response (response);
     return ret;
   }
-  response = MHD_create_response_from_buffer (strlen (PAGE),
-                                              PAGE,
-                                              MHD_RESPMEM_PERSISTENT);
+  response = MHD_create_response_from_buffer_static (strlen (PAGE),
+                                                     PAGE);
   ret = MHD_queue_response (connection,
                             MHD_HTTP_OK,
                             response);
diff --git a/src/testcurl/test_digestauth_with_arguments.c 
b/src/testcurl/test_digestauth_with_arguments.c
index 773fd5f5..843e4684 100644
--- a/src/testcurl/test_digestauth_with_arguments.c
+++ b/src/testcurl/test_digestauth_with_arguments.c
@@ -104,9 +104,8 @@ ahc_echo (void *cls,
   if ( (username == NULL) ||
        (0 != strcmp (username, "testuser")) )
   {
-    response = MHD_create_response_from_buffer (strlen (DENIED),
-                                                DENIED,
-                                                MHD_RESPMEM_PERSISTENT);
+    response = MHD_create_response_from_buffer_static (strlen (DENIED),
+                                                       DENIED);
     ret = MHD_queue_auth_fail_response2 (connection, realm,
                                          MY_OPAQUE,
                                          response,
@@ -123,9 +122,8 @@ ahc_echo (void *cls,
   MHD_free (username);
   if (ret_e != MHD_DAUTH_OK)
   {
-    response = MHD_create_response_from_buffer (strlen (DENIED),
-                                                DENIED,
-                                                MHD_RESPMEM_PERSISTENT);
+    response = MHD_create_response_from_buffer_static (strlen (DENIED),
+                                                       DENIED);
     if (NULL == response)
       return MHD_NO;
     ret = MHD_queue_auth_fail_response2 (connection, realm,
@@ -137,8 +135,8 @@ ahc_echo (void *cls,
     MHD_destroy_response (response);
     return ret;
   }
-  response = MHD_create_response_from_buffer (strlen (PAGE), PAGE,
-                                              MHD_RESPMEM_PERSISTENT);
+  response = MHD_create_response_from_buffer_static (strlen (PAGE),
+                                                     PAGE);
   ret = MHD_queue_response (connection, MHD_HTTP_OK, response);
   MHD_destroy_response (response);
   return ret;
diff --git a/src/testcurl/test_get.c b/src/testcurl/test_get.c
index a60c0797..8fe1c771 100644
--- a/src/testcurl/test_get.c
+++ b/src/testcurl/test_get.c
@@ -765,9 +765,7 @@ ahc_empty (void *cls,
     return MHD_YES;
   }
   *req_cls = NULL;
-  response = MHD_create_response_from_buffer (0,
-                                              NULL,
-                                              MHD_RESPMEM_PERSISTENT);
+  response = MHD_create_response_empty (MHD_RF_NONE);
   ret = MHD_queue_response (connection,
                             MHD_HTTP_OK,
                             response);
diff --git a/src/testcurl/test_get_chunked.c b/src/testcurl/test_get_chunked.c
index 876016cc..4f7b5606 100644
--- a/src/testcurl/test_get_chunked.c
+++ b/src/testcurl/test_get_chunked.c
@@ -232,8 +232,7 @@ ahc_echo (void *cls,
       free (buf);
     }
     else
-      response = MHD_create_response_from_buffer (0, NULL,
-                                                  MHD_RESPMEM_PERSISTENT);
+      response = MHD_create_response_empty (MHD_RF_NONE);
   }
   if (NULL == response)
     abort ();
diff --git a/src/testcurl/test_get_empty.c b/src/testcurl/test_get_empty.c
index fdbb2d42..32d6b16f 100644
--- a/src/testcurl/test_get_empty.c
+++ b/src/testcurl/test_get_empty.c
@@ -125,9 +125,7 @@ ahc_echo (void *cls,
     return MHD_YES;
   }
   *req_cls = NULL;
-  response = MHD_create_response_from_buffer (0,
-                                              NULL,
-                                              MHD_RESPMEM_PERSISTENT);
+  response = MHD_create_response_empty (MHD_RF_NONE);
   ret = MHD_queue_response (connection,
                             MHD_HTTP_NO_CONTENT,
                             response);
@@ -723,9 +721,7 @@ ahc_empty (void *cls,
     return MHD_YES;
   }
   *req_cls = NULL;
-  response = MHD_create_response_from_buffer (0,
-                                              NULL,
-                                              MHD_RESPMEM_PERSISTENT);
+  response = MHD_create_response_empty (MHD_RF_NONE);
   ret = MHD_queue_response (connection, MHD_HTTP_OK, response);
   MHD_destroy_response (response);
   if (ret == MHD_NO)
diff --git a/src/testcurl/test_post.c b/src/testcurl/test_post.c
index 90b8f48a..e36391fd 100644
--- a/src/testcurl/test_post.c
+++ b/src/testcurl/test_post.c
@@ -610,8 +610,7 @@ ahc_cancel (void *cls,
   {
     *req_cls = "wibble";
     /* We don't want the body. Send a 500. */
-    response = MHD_create_response_from_buffer (0, NULL,
-                                                MHD_RESPMEM_PERSISTENT);
+    response = MHD_create_response_empty (MHD_RF_NONE);
     ret = MHD_queue_response (connection, 500, response);
     if (ret != MHD_YES)
       fprintf (stderr, "Failed to queue response\n");
diff --git a/src/testcurl/test_post_loop.c b/src/testcurl/test_post_loop.c
index 37cd121b..ec42ffce 100644
--- a/src/testcurl/test_post_loop.c
+++ b/src/testcurl/test_post_loop.c
@@ -103,8 +103,8 @@ ahc_echo (void *cls,
   {
     if (*req_cls != &marker)
       abort ();
-    response = MHD_create_response_from_buffer (2, "OK",
-                                                MHD_RESPMEM_PERSISTENT);
+    response = MHD_create_response_from_buffer_static (2,
+                                                       "OK");
     ret = MHD_queue_response (connection, MHD_HTTP_OK, response);
     MHD_destroy_response (response);
     *req_cls = NULL;
diff --git a/src/testcurl/test_termination.c b/src/testcurl/test_termination.c
index 72b77219..239f10ec 100644
--- a/src/testcurl/test_termination.c
+++ b/src/testcurl/test_termination.c
@@ -78,8 +78,7 @@ connection_handler (void *cls,
   }
 
   response =
-    MHD_create_response_from_buffer (strlen ("Response"), "Response",
-                                     MHD_RESPMEM_PERSISTENT);
+    MHD_create_response_from_buffer_static (strlen ("Response"), "Response");
   ret = MHD_queue_response (connection, MHD_HTTP_OK, response);
   MHD_destroy_response (response);
 

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]