aboutsummaryrefslogtreecommitdiff
path: root/src/microhttpd/mhd_str.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/microhttpd/mhd_str.c')
-rw-r--r--src/microhttpd/mhd_str.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/microhttpd/mhd_str.c b/src/microhttpd/mhd_str.c
index 484de105..ece6ef44 100644
--- a/src/microhttpd/mhd_str.c
+++ b/src/microhttpd/mhd_str.c
@@ -627,7 +627,7 @@ MHD_str_remove_token_caseless_ (const char *str,
627 copy_size = (size_t) (s1 - cur_token); 627 copy_size = (size_t) (s1 - cur_token);
628 if (buf == s2) 628 if (buf == s2)
629 { /* The first token to copy to the output */ 629 { /* The first token to copy to the output */
630 if (buf + *buf_size < s2 + copy_size) 630 if (*buf_size < copy_size)
631 { /* Not enough space in the output buffer */ 631 { /* Not enough space in the output buffer */
632 *buf_size = (ssize_t) -1; 632 *buf_size = (ssize_t) -1;
633 return false; 633 return false;
@@ -635,7 +635,8 @@ MHD_str_remove_token_caseless_ (const char *str,
635 } 635 }
636 else 636 else
637 { /* Some token was already copied to the output buffer */ 637 { /* Some token was already copied to the output buffer */
638 if (buf + *buf_size < s2 + copy_size + 2) 638 mhd_assert (s2 > buf);
639 if (*buf_size < ((size_t) (s2 - buf)) + copy_size + 2)
639 { /* Not enough space in the output buffer */ 640 { /* Not enough space in the output buffer */
640 *buf_size = (ssize_t) -1; 641 *buf_size = (ssize_t) -1;
641 return false; 642 return false;
@@ -659,7 +660,8 @@ MHD_str_remove_token_caseless_ (const char *str,
659 while ( ((size_t) (s1 - str) < str_len) && 660 while ( ((size_t) (s1 - str) < str_len) &&
660 (',' != *s1) && (' ' != *s1) && ('\t' != *s1) ) 661 (',' != *s1) && (' ' != *s1) && ('\t' != *s1) )
661 { 662 {
662 if (buf + *buf_size <= s2) /* '<= s2' equals '< s2 + 1' */ 663 mhd_assert (s2 >= buf);
664 if (*buf_size <= (size_t) (s2 - buf)) /* '<= s2' equals '< s2 + 1' */
663 { /* Not enough space in the output buffer */ 665 { /* Not enough space in the output buffer */
664 *buf_size = (ssize_t) -1; 666 *buf_size = (ssize_t) -1;
665 return false; 667 return false;
@@ -678,7 +680,8 @@ MHD_str_remove_token_caseless_ (const char *str,
678 * the input string */ 680 * the input string */
679 if (((size_t) (s1 - str) < str_len) && (',' != *s1)) 681 if (((size_t) (s1 - str) < str_len) && (',' != *s1))
680 { /* Not the end of the current token */ 682 { /* Not the end of the current token */
681 if (buf + *buf_size <= s2) /* '<= s2' equals '< s2 + 1' */ 683 mhd_assert (s2 >= buf);
684 if (*buf_size <= (size_t) (s2 - buf)) /* '<= s2' equals '< s2 + 1' */
682 { /* Not enough space in the output buffer */ 685 { /* Not enough space in the output buffer */
683 *buf_size = (ssize_t) -1; 686 *buf_size = (ssize_t) -1;
684 return false; 687 return false;