[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[libmicrohttpd] branch master updated (7345c149 -> 6210a78f)
From: |
gnunet |
Subject: |
[libmicrohttpd] branch master updated (7345c149 -> 6210a78f) |
Date: |
Tue, 07 Sep 2021 12:39:08 +0200 |
This is an automated email from the git hooks/post-receive script.
karlson2k pushed a change to branch master
in repository libmicrohttpd.
from 7345c149 Fix for e2a52a91c687afc8f15b98a33ee6ed01a0a4a1ff
new af4f8885 mhd_str: rewrote one function to stop sanitizer alarming
new 6210a78f configure: spelling fixes
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 | 2 +-
m4/mhd_shutdown_socket_trigger.m4 | 2 +-
src/microhttpd/mhd_str.c | 119 ++++++++++++++++++++------------------
3 files changed, 65 insertions(+), 58 deletions(-)
diff --git a/configure.ac b/configure.ac
index 5568002c..5a5b82f0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -434,7 +434,7 @@ AM_CONDITIONAL([CYGWIN_TARGET], [[test "x$os_is_windows" =
"xyes" && \
AS_VAR_IF([os_is_windows], ["yes"],
[
- AC_MSG_CHECKING([[whether target W32 version is specified by precomiler
defines]])
+ AC_MSG_CHECKING([[whether target W32 version is specified by precompiler
defines]])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
/* Note: check logic is reversed for easy log reading */
#ifdef WINVER
diff --git a/m4/mhd_shutdown_socket_trigger.m4
b/m4/mhd_shutdown_socket_trigger.m4
index 1abe3b09..03a1df02 100644
--- a/m4/mhd_shutdown_socket_trigger.m4
+++ b/m4/mhd_shutdown_socket_trigger.m4
@@ -29,7 +29,7 @@ AC_DEFUN([MHD_CHECK_SOCKET_SHUTDOWN_TRIGGER],[dnl
AC_CHECK_HEADERS([time.h],[AC_CHECK_FUNCS([nanosleep])],[],
[AC_INCLUDES_DEFAULT])
AC_CHECK_HEADERS([unistd.h],[AC_CHECK_FUNCS([usleep])],[],
[AC_INCLUDES_DEFAULT])
AC_CHECK_HEADERS([string.h sys/types.h sys/socket.h netinet/in.h time.h
sys/select.h netinet/tcp.h],[],[], [AC_INCLUDES_DEFAULT])
- AC_CACHE_CHECK([[whether shutdown of listen socket trigger select()]],
+ AC_CACHE_CHECK([[whether shutdown of listen socket triggers select()]],
[[mhd_cv_host_shtdwn_trgr_select]], [dnl
_MHD_OS_KNOWN_SOCKET_SHUTDOWN_TRIGGER([[mhd_cv_host_shtdwn_trgr_select]])
AS_VAR_IF([mhd_cv_host_shtdwn_trgr_select], [["maybe"]],
diff --git a/src/microhttpd/mhd_str.c b/src/microhttpd/mhd_str.c
index 1c77a46d..3bbc6f42 100644
--- a/src/microhttpd/mhd_str.c
+++ b/src/microhttpd/mhd_str.c
@@ -718,44 +718,45 @@ MHD_str_remove_tokens_caseless_ (char *str,
const char *const tokens,
const size_t tokens_len)
{
- const char *t; /**< position in the @a tokens string */
+ const char *const t = tokens; /**< a short alias for @a tokens */
+ size_t pt; /**< position in @a tokens */
bool token_removed;
mhd_assert (NULL == memchr (tokens, 0, tokens_len));
token_removed = false;
- t = tokens;
+ pt = 0;
- while ((size_t) (t - tokens) < tokens_len && *str_len != 0)
+ while (pt < tokens_len && *str_len != 0)
{
const char *tkn; /**< the current token */
size_t tkn_len;
/* Skip any initial whitespaces and empty tokens in 'tokens' */
- while ( ((size_t) (t - tokens) < tokens_len) &&
- ((' ' == *t) || ('\t' == *t) || (',' == *t)) )
- t++;
+ while ( (pt < tokens_len) &&
+ ((' ' == t[pt]) || ('\t' == t[pt]) || (',' == t[pt])) )
+ pt++;
- if ((size_t) (t - tokens) >= tokens_len)
+ if (pt >= tokens_len)
break; /* No more tokens, nothing to remove */
/* Found non-whitespace char which is not a comma */
- tkn = t;
+ tkn = t + pt;
do
{
do
{
- t++;
- } while ((size_t) (t - tokens) < tokens_len && (' ' != *t && '\t' != *t
&&
- ',' != *t));
+ pt++;
+ } while (pt < tokens_len &&
+ (' ' != t[pt] && '\t' != t[pt] && ',' != t[pt]));
/* Found end of token string, space, tab, or comma */
- tkn_len = t - tkn;
+ tkn_len = pt - (size_t) (tkn - t);
/* Skip all spaces and tabs */
- while ((size_t) (t - tokens) < tokens_len && (' ' == *t || '\t' == *t))
- t++;
+ while (pt < tokens_len && (' ' == t[pt] || '\t' == t[pt]))
+ pt++;
/* Found end of token string or non-whitespace char */
- } while((size_t) (t - tokens) < tokens_len && ',' != *t);
+ } while(pt < tokens_len && ',' != t[pt]);
/* 'tkn' is the input token with 'tkn_len' chars */
mhd_assert (0 != tkn_len);
@@ -769,84 +770,90 @@ MHD_str_remove_tokens_caseless_ (char *str,
}
continue;
}
+ /* 'tkn' cannot match part of 'str' if length of 'tkn' is larger
+ * than length of 'str'.
+ * It's know that 'tkn' is not equal to the 'str' (was checked previously).
+ * As 'str' is normalized when 'tkn' is not equal to the 'str'
+ * it is required that 'str' to be at least 3 chars larger then 'tkn'
+ * (the comma, the space and at least one additional character)
+ * to remove 'tkn' from the 'str'. */
if (*str_len > tkn_len + 2)
{ /* Remove 'tkn' from the input string */
- const char *s1; /**< the "input" string / character */
- char *s2; /**< the "output" string / character */
+ size_t pr; /**< the 'read' position in the @a str */
+ size_t pw; /**< the 'write' position in the @a str */
- s1 = str;
- s2 = str;
+ pr = 0;
+ pw = 0;
do
{
- mhd_assert (s1 >= s2);
- mhd_assert ((str + *str_len) >= (s1 + tkn_len));
- if ( ( ((str + *str_len) == (s1 + tkn_len)) || (',' == s1[tkn_len]) )
&&
- MHD_str_equal_caseless_bin_n_ (s1, tkn, tkn_len) )
+ mhd_assert (pr >= pw);
+ mhd_assert ((*str_len) >= (pr + tkn_len));
+ if ( ( ((*str_len) == (pr + tkn_len)) || (',' == str[pr + tkn_len]) )
&&
+ MHD_str_equal_caseless_bin_n_ (str + pr, tkn, tkn_len) )
{
/* current token in the input string matches the 'tkn', skip it */
- mhd_assert ((str + *str_len == s1 + tkn_len) || \
- (',' == s1[tkn_len]));
- mhd_assert ((str + *str_len == s1 + tkn_len) || \
- (' ' == s1[tkn_len + 1]));
+ mhd_assert ((*str_len == pr + tkn_len) || \
+ (' ' == str[pr + tkn_len + 1])); /* 'str' must be
normalized */
token_removed = true;
/* Advance to the next token in the input string or beyond
* the end of the input string. */
- s1 += tkn_len + 2;
+ pr += tkn_len + 2;
}
else
{
/* current token in the input string does not match the 'tkn',
* copy to the output */
- if (str != s2)
+ if (0 != pw)
{ /* not the first output token, add ", " to separate */
- if (s1 != s2 + 2)
+ if (pr != pw + 2)
{
- *(s2++) = ',';
- *(s2++) = ' ';
+ str[pw++] = ',';
+ str[pw++] = ' ';
}
else
- s2 += 2;
+ pw += 2; /* 'str' is not yet modified in this round */
}
do
{
- if (s1 != s2)
- *s2 = *s1;
- s1++;
- s2++;
- } while (s1 < str + *str_len && ',' != *s1);
+ if (pr != pw)
+ str[pw] = str[pr];
+ pr++;
+ pw++;
+ } while (pr < *str_len && ',' != str[pr]);
/* Advance to the next token in the input string or beyond
* the end of the input string. */
- s1 += 2;
+ pr += 2;
}
- /* s1 should point to the next token in the input string or beyond
+ /* 'pr' should point to the next token in the input string or beyond
* the end of the input string */
- if ((str + *str_len) < (s1 + tkn_len))
- { /* The rest of the 's1' is too small to match 'tkn' */
- if ((str + *str_len) > s1)
+ if ((*str_len) < (pr + tkn_len))
+ { /* The rest of the 'str + pr' is too small to match 'tkn' */
+ if ((*str_len) > pr)
{ /* Copy the rest of the string */
size_t copy_size;
- copy_size = *str_len - (size_t) (s1 - str);
- if (str != s2)
+ copy_size = *str_len - pr;
+ if (0 != pw)
{ /* not the first output token, add ", " to separate */
- if (s1 != s2 + 2)
+ if (pr != pw + 2)
{
- *(s2++) = ',';
- *(s2++) = ' ';
+ str[pw++] = ',';
+ str[pw++] = ' ';
}
else
- s2 += 2;
+ pw += 2; /* 'str' is not yet modified in this round */
}
- if (s1 != s2)
- memmove (s2, s1, copy_size);
- s2 += copy_size;
+ if (pr != pw)
+ memmove (str + pw, str + pr, copy_size);
+ pw += copy_size;
}
- *str_len = s2 - str;
+ *str_len = pw;
break;
}
- mhd_assert ((' ' != s1[0]) && ('\t' != s1[0]));
- mhd_assert ((s1 == str) || (' ' == *(s1 - 1)));
- mhd_assert ((s1 == str) || (',' == *(s1 - 2)));
+ mhd_assert ((' ' != str[0]) && ('\t' != str[0]));
+ mhd_assert ((0 == pr) || (3 <= pr));
+ mhd_assert ((0 == pr) || (' ' == str[pr - 1]));
+ mhd_assert ((0 == pr) || (',' == str[pr - 2]));
} while (1);
}
}
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
- [libmicrohttpd] branch master updated (7345c149 -> 6210a78f),
gnunet <=