gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] [libmicrohttpd] branch master updated (2a0871b7 -> fc629fac


From: gnunet
Subject: [GNUnet-SVN] [libmicrohttpd] branch master updated (2a0871b7 -> fc629fac)
Date: Wed, 15 May 2019 23:24:20 +0200

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

karlson2k pushed a change to branch master
in repository libmicrohttpd.

    from 2a0871b7 Fixed build from source on GNU Hurd
     new 11350cbe More speedups by using predefined length of strings
     new fc629fac configure: fixed MS Lib utility detection after 
6ef94cf448e11a51c4b24d7347351047c39e3afe

The 2 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:
 configure.ac                |  3 ++-
 src/microhttpd/connection.c | 32 +++++++++++++++++++++-----------
 src/microhttpd/response.c   | 16 ++++++++++++----
 3 files changed, 35 insertions(+), 16 deletions(-)

diff --git a/configure.ac b/configure.ac
index eabfb0c8..53d37ca4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -55,6 +55,7 @@ AS_IF([test `uname -s` = "OS/390"],
 
 # Checks for programs.
 AC_PROG_AWK
+AC_PROG_GREP
 AC_PROG_INSTALL
 AC_PROG_LN_S
 AC_PROG_MAKE_SET
@@ -318,7 +319,7 @@ AS_CASE(["$host_os"],
      AC_CHECK_HEADERS([winsock2.h ws2tcpip.h], [], [AC_MSG_ERROR([[Winsock2 
headers are required for W32]])], [AC_INCLUDES_DEFAULT])
      AC_CACHE_CHECK([for MS lib utility], [ac_cv_use_ms_lib_tool],
        [mslibcheck=`lib 2>&1`
-        AS_IF([test $mslibcheck = "Microsoft (R) Library Manager"*],
+        AS_IF([echo "$mslibcheck" | $GREP -e '^Microsoft (R) Library Manager' 
- >/dev/null],
           [ac_cv_use_ms_lib_tool=yes],
           [ac_cv_use_ms_lib_tool=no])
          ])
diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c
index d3f47d4d..b73e6d5a 100644
--- a/src/microhttpd/connection.c
+++ b/src/microhttpd/connection.c
@@ -1010,6 +1010,8 @@ MHD_lookup_connection_value_n (struct MHD_Connection 
*connection,
  * Case-insensitive match used for header names and tokens.
  * @param connection the connection to get values from
  * @param header     the header name
+ * @param header_len the length of header, not including optional
+ *                   terminating null-character
  * @param token      the token to find
  * @param token_len  the length of token, not including optional
  *                   terminating null-character.
@@ -1019,6 +1021,7 @@ MHD_lookup_connection_value_n (struct MHD_Connection 
*connection,
 static bool
 MHD_lookup_header_token_ci (const struct MHD_Connection *connection,
                          const char *header,
+                         size_t header_len,
                          const char *token,
                          size_t token_len)
 {
@@ -1026,12 +1029,15 @@ MHD_lookup_header_token_ci (const struct MHD_Connection 
*connection,
 
   if (NULL == connection || NULL == header || 0 == header[0] || NULL == token 
|| 0 == token[0])
     return false;
+
   for (pos = connection->headers_received; NULL != pos; pos = pos->next)
     {
       if ((0 != (pos->kind & MHD_HEADER_KIND)) &&
+          (header_len == pos->header_size) &&
           ( (header == pos->header) ||
-            (MHD_str_equal_caseless_(header,
-                                      pos->header)) ) &&
+            (MHD_str_equal_caseless_bin_n_(header,
+                                           pos->header,
+                                           header_len)) ) &&
           (MHD_str_has_token_caseless_ (pos->value, token, token_len)))
         return true;
     }
@@ -1045,13 +1051,14 @@ MHD_lookup_header_token_ci (const struct MHD_Connection 
*connection,
  * Token could be surrounded by spaces and tabs and delimited by comma.
  * Case-insensitive match used for header names and tokens.
  * @param c   the connection to get values from
- * @param h   the header name
+ * @param h   the static string of header name
  * @param tkn the static string of token to find
  * @return true if token is found in specified header,
  *         false otherwise
  */
 #define MHD_lookup_header_s_token_ci(c,h,tkn) \
-    MHD_lookup_header_token_ci((c),(h),(tkn),MHD_STATICSTR_LEN_(tkn))
+    MHD_lookup_header_token_ci((c),(h),MHD_STATICSTR_LEN_(h),\
+                               (tkn),MHD_STATICSTR_LEN_(tkn))
 
 
 /**
@@ -1649,7 +1656,7 @@ build_header_response (struct MHD_Connection *connection)
   if (MHD_CONNECTION_FOOTERS_RECEIVED == connection->state)
     {
       reason_phrase = MHD_get_reason_phrase_for (rc);
-      MHD_snprintf_ (code,
+      off = MHD_snprintf_ (code,
                     sizeof (code),
                     "%s %u %s\r\n",
                     (0 != (connection->responseCode & MHD_ICY_FLAG))
@@ -1661,7 +1668,6 @@ build_header_response (struct MHD_Connection *connection)
                         : MHD_HTTP_VERSION_1_1),
                     rc,
                     reason_phrase);
-      off = strlen (code);
       /* estimate size */
       size = off + 2;           /* +2 for extra "\r\n" at the end */
       kind = MHD_HEADER_KIND;
@@ -1864,11 +1870,13 @@ build_header_response (struct MHD_Connection 
*connection)
       if ( (pos->kind == kind) &&
            (! ( (MHD_YES == must_add_close) &&
                 (response_has_keepalive) &&
-                (MHD_str_equal_caseless_(pos->header,
-                                         MHD_HTTP_HEADER_CONNECTION)) &&
+                (pos->header_size == 
MHD_STATICSTR_LEN_(MHD_HTTP_HEADER_CONNECTION)) &&
+                (MHD_str_equal_caseless_bin_n_(pos->header,
+                                               MHD_HTTP_HEADER_CONNECTION,
+                                               
MHD_STATICSTR_LEN_(MHD_HTTP_HEADER_CONNECTION))) &&
                 (MHD_str_equal_caseless_(pos->value,
                                          "Keep-Alive")) ) ) )
-        size += strlen (pos->header) + strlen (pos->value) + 4; /* colon, 
space, linefeeds */
+        size += pos->header_size + pos->value_size + 4; /* colon, space, 
linefeeds */
     }
   /* produce data */
   data = MHD_pool_allocate (connection->pool,
@@ -1926,8 +1934,10 @@ build_header_response (struct MHD_Connection *connection)
       if ( (pos->kind == kind) &&
            (! ( (MHD_YES == must_add_close) &&
                 (response_has_keepalive) &&
-                (MHD_str_equal_caseless_(pos->header,
-                                         MHD_HTTP_HEADER_CONNECTION)) &&
+                (pos->header_size == 
MHD_STATICSTR_LEN_(MHD_HTTP_HEADER_CONNECTION)) &&
+                (MHD_str_equal_caseless_bin_n_(pos->header,
+                                               MHD_HTTP_HEADER_CONNECTION,
+                                               
MHD_STATICSTR_LEN_(MHD_HTTP_HEADER_CONNECTION))) &&
                 (MHD_str_equal_caseless_(pos->value,
                                          "Keep-Alive")) ) ) )
         off += MHD_snprintf_ (&data[off],
diff --git a/src/microhttpd/response.c b/src/microhttpd/response.c
index 7d7e899b..f43ca541 100644
--- a/src/microhttpd/response.c
+++ b/src/microhttpd/response.c
@@ -199,18 +199,26 @@ MHD_del_response_header (struct MHD_Response *response,
 {
   struct MHD_HTTP_Header *pos;
   struct MHD_HTTP_Header *prev;
+  size_t header_len;
+  size_t content_len;
 
   if ( (NULL == header) ||
   (NULL == content) )
     return MHD_NO;
+  header_len = strlen (header);
+  content_len = strlen (content);
   prev = NULL;
   pos = response->first_header;
   while (NULL != pos)
     {
-      if ((0 == strcmp (header,
-                        pos->header)) &&
-          (0 == strcmp (content,
-                        pos->value)))
+      if ((header_len == pos->header_size) &&
+          (content_len == pos->value_size) &&
+          (0 == memcmp (header,
+                        pos->header,
+                        header_len)) &&
+          (0 == memcmp (content,
+                        pos->value,
+                        content_len)))
         {
           free (pos->header);
           free (pos->value);

-- 
To stop receiving notification emails like this one, please contact
address@hidden



reply via email to

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